title: Implementing a Binary Search Tree - Contains method
body: <p>I currently have 3 classes - DictionaryApp, BSTSet and BSTNode - both the BSTSet and BSTNode have contains methods.</p>
  
  <pre><code>public class BSTSet &lt;E extends Comparable&lt;E&gt;&gt; extends AbstractSet &lt;E&gt; {
  
      // the root of the supporting binary search tree
      private BSTNode&lt;E&gt; root;
  
      // number of elements in the set
      private int count = 0;
  
  
      public boolean isEmpty() {
          return count == 0;
      }
  
  
      public boolean contains(E item) throws ClassCastException {
          if(root == null) return false;
          return root.contains(item);
      }
  
      public boolean add(E item) {
          if (item == null) 
              throw new IllegalArgumentException("Null cannot be added to a BSTSet");
          if(contains(item))return false;
          if(root == null){
              root = new BSTNode(item);
              count++;
              return true;
          }else{
              root.add(item);
              count++;
              return true;
          }
      }
  }
  
  
  public class BSTNode &lt;E extends Comparable&lt;E&gt;&gt; {
  
      private E value;
      private BSTNode&lt;E&gt; left;
      public BSTNode&lt;E&gt; right;
  
      public BSTNode(E value) {
      this.value = value;
      }
  
      public E getValue() {
          return value;
      }
  
      public BSTNode&lt;E&gt; getLeft() {
          return left;
      }
  
      public BSTNode&lt;E&gt; getRight() {
          return right;
      }
  
  
      public boolean contains(E item) {
          if(item.compareTo(value) == 0) return true;
          if(left != null) left.contains(item);
          if(right != null) right.contains(item);
          // no matching node was found
          return false;
  
      }
  
       public boolean add(E item) {
          if(item.compareTo(value) &lt; 0) {left = new BSTNode(item); return true;}
          if(item.compareTo(value) &gt; 0) {right = new BSTNode(item); return true;}
          return false;
      }
  }
  </code></pre>
  
  <p>My issues is that the contains method in the BSTNode class never returns true and I can't understand why. If you would like to see anymore of my code or need anymore information please feel free to ask.</p>