def insert_element_to_dict_of_dicts_of_list(dict_of_dict_of_list, first_key, second_key, parser):
    """
    Utility method

    :param dict_of_dict_of_list:
    :param first_key:
    :param second_key:
    :param parser:
    :return:
    """
    list_to_insert = parser if isinstance(parser, list) else [parser]

    if first_key not in dict_of_dict_of_list.keys():
        dict_of_dict_of_list[first_key] = {second_key: list_to_insert}
    else:
        if second_key not in dict_of_dict_of_list[first_key].keys():
            dict_of_dict_of_list[first_key][second_key] = list_to_insert
        else:
            dict_of_dict_of_list[first_key][second_key] += list_to_insert
def insert_element_to_dict_of_dicts_of_list ( dict_of_dict_of_list , first_key , second_key , parser ) : list_to_insert = parser if isinstance ( parser , list ) else [ parser ] if first_key not in dict_of_dict_of_list . keys ( ) : dict_of_dict_of_list [ first_key ] = { second_key : list_to_insert } else : if second_key not in dict_of_dict_of_list [ first_key ] . keys ( ) : dict_of_dict_of_list [ first_key ] [ second_key ] = list_to_insert else : dict_of_dict_of_list [ first_key ] [ second_key ] += list_to_insert
Utility method

    :param dict_of_dict_of_list:
    :param first_key:
    :param second_key:
    :param parser:
    :return: