// order of returned elements is undefined, but root is returned first // doesn't uniquify output, so make sure you don't produce a loop static ItIt recursiveIterator(A root, IF1> getChildren) { LinkedList list = llLinkedList(root); ret iff(func { if (empty(list)) ret endMarker(); A a = popFirst(list); addAll(list, getChildren.get(a)); ret a; }); }