def flatten(structure, key='', path='', flattened=None):
    if flattened is None:
        pass
Flattening a list of dicts of lists of dicts (etc) of unknown depth in Python (nightmarish JSON structure)