def collapse_record(record, separator = '.', root = None):

    result = {}
    for key, value in record.items():
        if root:
            collapsed_key = root + separator + key
        else:
            collapsed_key = key

        if type(value) == dict:
            collapsed = collapse_record(value, separator, collapsed_key)
            result.update(collapsed)
        else:
            result[collapsed_key] = value
    return result
See :func:`brewery.expand_record` for reverse operation.
dataset/ETHPy150Open Stiivi/brewery/brewery/metadata.py/collapse_record