private static int countNodes ( TreeModel treeModel , Object node ) { int sum = 1 ; int n = treeModel . getChildCount ( node ) ; for ( int i = 0 ; i < n ; i ++ ) { sum += countNodes ( treeModel , treeModel . getChild ( node , i ) ) ; } return sum ; }
Recursively count the number of nodes in the given tree model starting with the given node