def tree_unflatten(flat):
    """Nest depth-1 tree to nested tree 
            {'a.b.c': x} -> {'a': {'b': {'c': x}}} """
    def recursion(k, v, out):
        k, *rest = k.split('.', 1)
        if rest:
            recursion(rest[0], v, out.setdefault(k, {}))
        else:
            out[k] = v
    d = {}
    for k, v in flat.items():
        recursion(k, v, d)
    return d