def reduce_to_dict(    
    arr, key_name, col_name_primary, col_name_secondary=None
):
    """returns dict with selected columns as key and value from list of dict
    
    Args:
        arr: list of dicts to reduce
        key_name: name of column to become key
        col_name_primary: colum will become value if it exists
        col_name_secondary: colum will become value if col_name_primary 
            does not exist and this argument is provided

    dict items with no matching key_name, col_name_primary and 
    col_name_secondary will not be included in the resulting new dict

    """
    arr2 = dict()
    for item in arr:
        if key_name in item:
            key = item[key_name]
            if col_name_primary in item:
                arr2[key] = item[col_name_primary]
            elif (
                col_name_secondary is not None 
                and col_name_secondary in item
            ):
                arr2[key] = item[col_name_secondary]            
    return arr2