title: calculating the depth of polymorphic bst object recursively
body: <p>I'm trying to calculate the depth of a key in a polymorphic bst (instead of null objects empty objects are denoted by EmptyTrees) and I'm not sure how to implement the actual code. </p>
  
  <pre><code>private int calcDepth(K keyIn, int level){ 
   if (this.key.compareTo(keyIn) == 0) return level; 
  
    if (this.key.compareTo(keyIn) &lt; 0){ 
    return left.calcDepth(keyIn, level+1); 
    }
  
    if (this.key.compareTo(keyIn) &gt; 0){ 
    return right.calcDepth(keyIn, level+1); 
    }
  
    return -1; 
  }
  </code></pre>
  
  <p>I'm very new to java so forgive the basic and or confused nature of the question</p>
  
  <p>So my question is, how do i calculate the depth of a key in my bst? </p>