def getSubOrder(existing):
    alpha = list(zip(*sorted(((k, v['rec']['label']) for k, v in existing.items()), key=lambda a: a[1])))[0]
    depths = {}
    def getDepth(id_):
        if id_ in depths:
            return depths[id_]
        else:
            if id_ in existing:
                names_above = getDepth(existing[id_]['sc'])
                depths[id_] = names_above + [existing[id_]['rec']['label']]
                return depths[id_]
            else:
                return ['']
    for id_ in existing:
        getDepth(id_)
    print(sorted(depths.values()))
    def key_(id_):
        return depths[id_]
    return sorted(depths, key=key_)