title: Test if two binary search trees has the same set of elements?
body: <p>I am just starting out with java and recursive methods and i need some help:
  I need to determine if two Binary Search Trees has exactly the same set of elements, regardless of the structure of the tree. </p>
  
  <p>I have written a method that checks if the the tree contains an element and its called contains()</p>
  
  <p>this is what i got so far:</p>
  
  <pre><code>    public boolean sameContents(Node n2) {
  
      if (contains(n2, n2.key) &amp;&amp; n2.left == null &amp;&amp; n2.right == null) { return true; }
      if (contains(n2, n2.key) &amp;&amp; n2.left != null) { sameContents(n2.left); }
      if (contains(n2, n2.key) &amp;&amp; n2.right != null) { sameContents(n2.right); }
       return false; 
     }
  </code></pre>
  
  <p>Basicly my idea is that the method is running as long as a node still has a child, and if the trees match.
  I call the method with for example testTree1.sameContents(testTree2); but the method always returns false... 
  Can someone point out how this should be done?</p>