I'm the person who submitted the bug report to O'Reilly about the problem with Composite Iterator. I thought that my comments would go to the authors, which is why I made them sketchy. If I knew that they were being sent out to the public, then I would have been more clear.
The basic idea is that there are two kinds of iteration going on in the code: the iterator method that clients call, and the iterator that gets the children of a composite node. You cannot use the same method to do both things. (And even if you could, it would be bad style.) So I introduce the method childIterator to do the latter iteration. Once you see the need for two distinct methods, the code is pretty straightforward to write, and hopefully straightforward to read.
Anyway, I taught an OOP course here at Boston College using the HeadFirst design Patterns book. It's a great book. But the Composite Iterator chapter is very badly written and wrong in several places. The URL for my course is
http://www.cs.bc.edu/~sciore/courses/cs353/coverage.html My explanation of the problem and solution is towards the end of the lecture notes for class #23. My code appears in the "Menu Iterator" handout from that class.
Comments on that class or any others are appreciated.
Ed