title: Fixing my implementation of "inorder tree traversal" algorithm with a Stack
body: <p>Part of it is that I have to implement a non-recursive method of a inorder traversal of a binary tree. I am kind of stuck. Here is what I have so far:</p>
  
  
  
  <pre><code>public void inorder(BinaryTree v) {
      Stack&lt;BinaryTree&gt; stack = new Stack&lt;BinaryTree&gt;();
      stack.push(v);
      System.out.println(v.getValue());
  
      while(!stack.isEmpty()) {
          while(v.getLeft() != null) {
              v = v.getLeft();
              stack.push(v);
              System.out.println(v.getValue());
          }
  
          while(v.getRight() != null) {
              v = v.getRight();
              stack.push(v);
              System.out.println(v.getValue());
          }
                  stack.pop();
      }
  }
  </code></pre>
  
  <p>I noticed that it only prints out the left side of my tree, e.g.</p>
  
  <pre><code>          A
          /   \
         B     C
       /   \  /  \
      D     E F   G
     /  \
    H     I
   / \
  J   K
  </code></pre>
  
  <p>Gives <code>A B D H J</code></p>