Generic Tree Iterator

Tree iterator is a convinient and easy-to-use tree-traversing Java utility suitable for any kind of tree. It employs pre-order tree traversal algorithm (node is processed before its children). Two things set the tree iterator apart from a traditional way of traversing a treelike structure:

  • Tree iterator is generic. It can traverse any type of a treelike structure as long as the appropriate adapter class is provided. Adapters for DOM tree and Swing (javax.swing.tree.TreeNode) are provided with the iterator.
  • Tree iterator is also capable of performing selective traversal. For example, it is possible to direct iterator to skip certain branches of a tree based on some criteria. Or, alternatively, calling code can dynamically change the depth of the traversal for different branches.
The tree iterator was featured in the "Generic tree traversal" article in the November, 2000 issue of Doctor Dobb's Journal.

Documentation:

Programmer's Guide

Javadoc API