@classmethod
def nested(cls, src: dict, delim: str, root_key: str) ->'package':
    """ Split all keys in <src> on <delim> and nest package dicts in a hierarchy based on these splits.
            If one key is a prefix of another, it may occupy a slot needed for another level of dicts.
            If this happens, move the value one level deeper under <root_key>. """
    pkg = cls()
    for k, v in src.items():
        d = pkg
        *first, last = k.split(delim)
        for i in first:
            if i not in d:
                d[i] = cls()
            elif not isinstance(d[i], cls):
                d[i] = cls({root_key: d[i]})
            d = d[i]
        if last not in d or not isinstance(d[last], cls):
            d[last] = v
        else:
            d[last][root_key] = v
    return pkg
