def _count_clades(trees):
 bitstrs = {}
 tree_count = 0
 for tree in trees:
  tree_count += 1
  clade_bitstrs = _tree_to_bitstrs(tree)
  for clade in tree.find_clades(terminal=False):
   bitstr = clade_bitstrs[clade]
   if (bitstr in bitstrs):
    (count, sum_bl) = bitstrs[bitstr]
    count += 1
    sum_bl += (clade.branch_length or 0)
    bitstrs[bitstr] = (count, sum_bl)
   else:
    bitstrs[bitstr] = (1, (clade.branch_length or 0))
 return (bitstrs, tree_count)

def _count_clades ( trees ) : bitstrs = { } tree_count = 0 for tree in trees : tree_count += 1 clade_bitstrs = _tree_to_bitstrs ( tree ) for clade in tree . find_clades ( terminal = False ) : bitstr = clade_bitstrs [ clade ] if ( bitstr in bitstrs ) : ( count , sum_bl ) = bitstrs [ bitstr ] count += 1 sum_bl += ( clade . branch_length or 0 ) bitstrs [ bitstr ] = ( count , sum_bl ) else : bitstrs [ bitstr ] = ( 1 , ( clade . branch_length or 0 ) ) return ( bitstrs , tree_count )
count distinct clades in the trees .