title: Creating a recursive iterator
body: <p>I am trying to write an iterator for a hierarchy of classes that collectively make up the components of a song. All classes are implementations of the abstract <code>MusicComponent</code> base class and inherit a <code>getChildren()</code> function. The abstract <code>MusicTime</code> subclass knows the actual note/chord to play, and all its implementations (e.g. quaver, crotchet) return <code>null</code> for <code>getChildren()</code>.</p>
  
  <p>The other components are <code>MusicComponent</code> which holds a collection of <code>MusicTimes</code> e.g. a bar at a time, and <code>Section</code> which holds the <code>MusicComponents</code>. <code>Song</code> holds the <code>Sections</code> that make up the song e.g. verses, choruses, sections with different tempos/time signatures.</p>
  
  <p>What I need is an iterator that will iterate through all <code>Sections</code> in a <code>Song</code>, then all <code>MusicComponents</code> in the <code>Section</code> and only when it finds a <code>MusicTime</code> descendant, play the note for the length of time based on its note type, and the time signature and tempo of its containing <code>Section</code>.</p>
  
  <p>Sorry if too much info, but was the only way I could explain what I'm trying to do. So do I need to handle this with a stack, recording which <code>MusicComponents</code> I've visted or is there a way to do this just using recursion?</p>