<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def tree_prune_tax_ids(self, tree, tax_ids):
 """Prunes a tree back to contain only the tax_ids in the list and their parents. Parameters tree : `skbio.tree.TreeNode` The root node of the tree to perform this operation on. tax_ids : `list` A `list` of taxonomic IDs to keep in the tree. Returns ------- `skbio.tree.TreeNode`, the root of a tree containing the given taxonomic IDs and their parents, leading back to the root node. """

        tax_ids_to_keep = []

        for tax_id in tax_ids:
            tax_ids_to_keep.append(tax_id)
            tax_ids_to_keep.extend([x.name for x in tree.find(tax_id).ancestors()])

        tree = tree.copy()
        tree.remove_deleted(lambda n: n.name not in tax_ids_to_keep)

        return tree