def removeLeaf(work, path):
    """remove leaf/branch at *path*.

    raises KeyError if path is not found.
    """
    if len(path) == 0:
        work.clear()
    else:
        for x in path[:-1]:
            work = work[x]
        del work[path[-1]]
    return work
