Remove the dead branches of tree, that is, the resulting tree accepts
        the same language as the original one (that is, the same words that end
        with the < character), but parts of the tree that lead to nothing are
        removed.

        :param tree: the tree;
        :return: the tree without dead branches.

def trim_tree(tree):
        """
        Remove the dead branches of tree, that is, the resulting tree accepts
        the same language as the original one (that is, the same words that end
        with the < character), but parts of the tree that lead to nothing are
        removed.

        :param tree: the tree;
        :return: the tree without dead branches.
        """
        # Remove empty nodes
        new_tree = {k: v for k, v in tree.items() if v}
        # Remove missing successors
        new_tree = {k: {successor: weight for successor, weight in v.items()
                        if successor in new_tree or successor[0] == "<"}
                    for k, v in new_tree.items()}
        while tree != new_tree:
            tree = new_tree
            # Remove empty nodes
            new_tree = {k: v for k, v in tree.items() if v}
            # Remove missing successors
            new_tree = {k: {successor: weight
                            for successor, weight in v.items()
                            if successor in new_tree or successor[0] == "<"}
                        for k, v in new_tree.items()}
        return new_tree