

def undunder_keys(_dict):
    "Returns dict with the dunder keys converted back to nested dicts\n\n    eg::\n\n        >>> undunder_keys({'a': 'hello', 'b__c': 'world'})\n        {'a': 'hello', 'b': {'c': 'world'}}\n\n    :param _dict : (dict) flat dict\n    :rtype       : (dict) nested dict\n\n    "

    def f(key, value):
        parts = key.split('__')
        return {
            parts[0]: (value if (len(parts) == 1) else f(parts[1], value)),
        }
    result = {
        
    }
    for r in [f(k, v) for (k, v) in _dict.items()]:
        rk = list(r.keys())[0]
        if (rk not in result):
            result.update(r)
        else:
            result[rk].update(r[rk])
    return result

dataset/ETHPy150Open naiquevin/lookupy/lookupy/dunderkey.py undunder_keys/original