title: Function to find number of nodes below a certain depth of a BST
body: <p>I'm trying to make a function that will count the number of nodes greater than a certain depth "k".</p>
  
  <p>Here is my code of the function for traversing the tree and a helper function for finding the depth of each node:</p>
  
  <pre><code>    int findDepth(BinaryNode * t, int value, int depth){
  
      if( t == nullptr ){
          return 0;
      }
      if( t-&gt;element == value){
          return depth;
      }
      int lowerDepth = findDepth(t-&gt;left, value, depth+1);
  
      if(lowerDepth != 0){
          return lowerDepth;
      }
      lowerDepth = findDepth(t-&gt;right, value, depth+1);
  
      return lowerDepth;
  
  }
  
  int countDeep( BinaryNode * t, int k ){
      int count = 0;
      if (t != nullptr){
          countDeep( t-&gt;left, k );
          if (findDepth(t, t-&gt;element, 0)){
              count++;
          }
          countDeep( t-&gt;right, k );
      }
      return count;
  }
  </code></pre>
  
  <p>Right now the function always returns 0 and I'm not quite sure why.</p>