title: Building a Binary Tree Class problems with isLeaf, isParent, and unsure about weight
body: <p>I am working on completing a Binary Tree class given to us by our professor, and I've gotten the methods to work fairly well, but have run into some problems with isLeaf(E value) and isParent(E value). Each method works, until you add something with the same data as an object already in the tree. Is there any way I can make sure it is checking each node, rather than checking the initial nodes multiple times? Also I am not sure if my weight method is working correctly? How exactly do you calculate the weight of an binary tree?</p>
  
  <pre><code>    public boolean isLeaf(E value){
              return this.isLeaf(root, value);
      }
  
      private boolean isLeaf(TreeNode&lt;E&gt; current, E value) {
          if (current == null){
              return false;
          }
          else if(current.getData().equals(value)) {
              if (current.getLeft() == null &amp;&amp; current.getRight() ==null) {
                  return true;
              }
              else{
                  return false;
              }
          }
          else if (this.contains(current.getLeft(), value)) {
              return this.isLeaf(current.getLeft(), value);
          }
          else {
              return this.isLeaf(current.getRight(), value);        }
      }
      public boolean isParent(E value){
              return this.isParent(root, value);
      }
  
      private boolean isParent(TreeNode&lt;E&gt; current, E value) {
          if (current == null){
              return false;
          }
          else if(value.equals(current.getData())) {
              if (current.getLeft() != null || current.getRight() != null) {
                  return true;
              }
              else{
                  return false;
              }
          }
          else if (this.contains(current.getLeft(), value)) {
              return this.isParent(current.getLeft(), value);
          }
          else {
              return this.isParent(current.getRight(), value);
          }
      }
  
      public int height(){
          return this.height(root);
      }
  
      private int height(TreeNode&lt;E&gt; current) {
          if(current == null){
              return 0;
          }
          else{
              if(this.height(current.getRight()) &lt; this.height(current.getLeft())){
                  return 1 + this.height(current.getLeft());
              }
              else{
                  return 1 + this.height(current.getRight());
              }
          }
      }
  
      public int weight(){
          return this.weight(root);
      }
  
      private int weight(TreeNode&lt;E&gt; current){
          if(current == null){
              return 0;
          }
          else{
              return 1 + this.height(current) * (this.weight(current.getLeft())
                       +  this.weight(current.getRight()));
          }
      }
  </code></pre>