def _paths_to_tree(paths):
    """Build a tree from the given paths.

    The structure of the tree is described in the docstring for _prune_paths.
    """

    tree = {}
    for path in paths:
        t = tree
        for c in path:
            if c not in t:
                t[c] = {}
            t = t[c]
    return tree