make_tree#

pyinaturalist.models.make_tree(taxa, include_ranks=None, sort_key=None)#

Organize a list of taxa into a taxonomic tree. Expects exactly one root taxon.

Parameters:
  • sort_key (Optional[Callable[[Taxon], Any]]) – Key function for sorting children; defaults to rank and name

  • include_ranks (Optional[List[str]]) – If provided, only include taxa with these ranks; otherwise, include all ranks

Return type:

Taxon

Returns:

Root taxon of the tree