Skip to main content
`Ctrl`+`K`

# skbio.tree.TreeNode.find_by_func

TreeNode.find_by_func(func)

  Find all nodes in a tree that meet certain criteria.

  Parameters:
    func callable

      A function that accepts a `TreeNode` and returns True or False, where True indicates the node is to be yielded.

  Yields:
    TreeNode

      The found node.

  See also

  `find`
  `find_all`
  `find_by_id`

  Notes

  This search method is based on the current subtree, not the root.

  This method does not cache search results.

  Examples

      >>> from skbio import TreeNode
      >>> tree = TreeNode.read(["((a,b)c,(d,e)f);"])
      >>> func = lambda x: x.parent == tree.find('c')
      >>> [n.name for n in tree.find_by_func(func)]
      ['a', 'b']