title: Iterate through binary search tree to find all leaves
body: <p>I am pretty new to trees, and I am trying to create kind of a "leaf iterator". I'm thinking it should put all nodes that does not have a <code>.left</code> and <code>.right</code> value onto a stack, but I'm not sure how or even if it's the right thing to do. I have tried searching for it, but every example I come over starts with going to the leftmost leaf, and going <code>p = node.parent</code>, and I am avoiding linking to the node's parent.</p>
  
  <p>I don't understand how I can repeatedlty start from the root and go through the vines without visiting the same vines over and over.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I see people suggests using a recursive method to solve this, and I agree now. But I have been banging my head trying to find the solution for an iterator-class-way to do this for a while, and I still would like to know if that's possible, and how!</p>