def _unflatten(fd, sep='_'):
    """
    Unflatten a dictionary or other nested structure into a nested
    dictionary.
    
    Parameters
    ----------
    fd : dictionary
        Flattend dictionary.
    sep : string
        String at which keys are split. 
    
    Returns
    -------
    Nested dictionary of unflattened structure.
    
    """
    ud = dict()
    for k, v in fd.items():
        new_ks = k.split(sep)
        d = ud
        for new_k in new_ks[:-1]:
            if new_k not in d:
                d[new_k] = dict()
            d = d[new_k]
        d[new_ks[-1]] = v
    return ud
