public static void printStats(TaxonomyReader r,PrintStream out,boolean printTree) throws IOException {
  out.println(r.getSize() + " total categories.");
  ChildrenIterator it=r.getChildren(TaxonomyReader.ROOT_ORDINAL);
  int child;
  while ((child=it.next()) != TaxonomyReader.INVALID_ORDINAL) {
    ChildrenIterator chilrenIt=r.getChildren(child);
    int numImmediateChildren=0;
    while (chilrenIt.next() != TaxonomyReader.INVALID_ORDINAL) {
      numImmediateChildren++;
    }
    FacetLabel cp=r.getPath(child);
    out.println("/" + cp.components[0] + ": "+ numImmediateChildren+ " immediate children; "+ (1 + countAllChildren(r,child))+ " total categories");
    if (printTree) {
      printAllChildren(out,r,child,"  ",1);
    }
  }
}

public static void printStats ( TaxonomyReader r , PrintStream out , boolean printTree ) throws IOException { out . println ( r . getSize ( ) + " total categories." ) ; ChildrenIterator it = r . getChildren ( TaxonomyReader . ROOT_ORDINAL ) ; int child ; while ( ( child = it . next ( ) ) != TaxonomyReader . INVALID_ORDINAL ) { ChildrenIterator chilrenIt = r . getChildren ( child ) ; int numImmediateChildren = 0 ; while ( chilrenIt . next ( ) != TaxonomyReader . INVALID_ORDINAL ) { numImmediateChildren ++ ; } FacetLabel cp = r . getPath ( child ) ; out . println ( "/" + cp . components [ 0 ] + ": " + numImmediateChildren + " immediate children; " + ( 1 + countAllChildren ( r , child ) ) + " total categories" ) ; if ( printTree ) { printAllChildren ( out , r , child , "  " , 1 ) ; } } }
recursively prints stats for all ordinals .
