def find_key_symptom(tariffs, cause_reduction, cause, endorsements,
                     rules=None):
    """Find the key endorsed symptom for a cause

    Args:
        tariffs (dict): processed tariff matrix
        cause_reduction (dict): mapping from cause46 to cause34
        cause (int): cause number at the cause34 level
        endorsements (iterable): names of endorsed symptoms
        rules (dict): mapping of rule-based cause prediction to key symptom

    Returns:
        symptom (str): name of the key symptom
    """
    rules = rules or {}
    rule_symp = rules.get(cause)
    if rule_symp:
        return rule_symp

    causes46s = [cause46 for cause46, cause34 in cause_reduction.items()
                 if cause34 == cause]
    values = {}
    for cause46 in causes46s:
        for symptom, tariff in tariffs[cause46]:
            if symptom not in endorsements or tariff <= 0:
                continue

            if symptom in values and values[symptom] < tariff:
                continue
            else:
                values[symptom] = tariff

    if values:
        return sorted(values.items(), key=lambda x: x[1])[-1][0]