<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_rank(self, tree, rank="species"):
 """Takes a TreeNode tree and prunes off any tips not at the specified rank and backwards up until all of the tips are at the specified rank. Parameters tree : `skbio.tree.TreeNode` The root node of the tree to perform this operation on. rank : {kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species'}, optional Analysis will be restricted to abundances of taxa at the specified level. Returns ------- `skbio.tree.TreeNode`, the root of the tree where all tips are at the given rank, and all tips have a path back to the root node. Examples -------- tree_prune_rank(tree, 'species') will remove all subspecies/strain nodes and return a tree containing all genus-level nodes and higher. """

        if rank is None:
            return tree.copy()

        tree = tree.copy()

        for node in tree.postorder():
            if node.rank == rank:
                node._above_rank = True
            elif any([getattr(n, "_above_rank", False) for n in node.children]):
                node._above_rank = True
            else:
                node._above_rank = False

        tree.remove_deleted(lambda n: not getattr(n, "_above_rank", False))

        return tree