# skbio.tree.TreeNode.prune

`TreeNode.``prune`()

  Reconstructs correct topology after nodes have been removed.

  State: Experimental as of 0.4.0.

  Internal nodes with only one child will be removed and new connections will be made to reflect change. This method is useful to call following node removals as it will clean up nodes with singular children.

  Names and properties of singular children will override the names and properties of their parents following the prune.

  Node lookup caches are invalidated.

  See also

  `shear`, `remove`, `pop`, `remove_deleted`

  Examples

      >>> from skbio import TreeNode
      >>> tree = TreeNode.read(["((a,b)c,(d,e)f)root;"])
      >>> to_delete = tree.find('b')
      >>> tree.remove_deleted(lambda x: x == to_delete)
      >>> print(tree)
      ((a)c,(d,e)f)root;

      >>> tree.prune()
      >>> print(tree)
      ((d,e)f,a)root;