Node class in Groovy has the methods
breadthFirst to return a collection of
Node objects using either depth or breadth first traversal. Since Groovy 2.5.0 we can specify if we want to use preorder (the default) or postorder traversal. Also the methods now accept a
Closure that will be invoked for each visited node. The
Closure has the current
Node as first argument, the second argument is the tree level of the current node.