title: Traversing Huffman Tree in Java
body: <p>I'm trying to use a recursive method to traverse a Huffman tree, and for each leaf node, add a Code record to an ArrayList. This is what I have so far.</p>
  
  <pre><code>private void traverse(ArrayList&lt;Code&gt; code, BinaryTreeNode&lt;Letter&gt; node,
                       String prefix) {
          // TODO:  Fill in this method
      if (root!=null){
          traverse(code, node.left, prefix);
      }
      if (root!=null){
          traverse(code, node.right, prefix);
      }
      if(node.left==null &amp;&amp; node.right==null){
          code.add(node);
      }
  </code></pre>
  
  <p>The code.add(node) is giving an error as well.</p>