Iterator

Implementation of an iterator that goes thru a Component and all its sub-components in a tree (pre-order) traversal. A test case that demonstrates the usage is also included, along with wrapping to make these iterators accessible from scripting..
It took me a long time to figure out what this code is doing, and I'm still not sure I understand it totally. It would be a lot easier if it were explained in English! Looks like a good trick, but nonobvious. One thing I still can't tell is what the overall structure of calls to this method looks like. I see "root" being passed in -- does this get called once only or again on the way down the tree? If the latter, then it would have O(n^2) runtime I think since the lower subcomponents woudl get done repeatedly.

In any case why not take pity on future programmers and explain this now while you still understand it?