def get_value(obj,key,create = False):
    key_fragments = key.split(".")
    current_dict = obj
    last_dict = None
    last_key = None
    for key_fragment in key_fragments:
        try:
            if create and not key_fragment in current_dict:
                current_dict[key_fragment] = {}
        except TypeError:
            if last_dict:
                last_dict[last_key] = {key_fragment : {}}
                current_dict = last_dict[last_key]
            else:
                raise KeyError
        last_key = key_fragment
        last_dict = current_dict
        try:
            current_dict = current_dict[key_fragment]
        except __HOLE__:
            raise KeyError
    return current_dict
dataset/ETHPy150Open adewes/blitzdb/blitzdb/helpers.py/get_value