title: Binary Tree - Method to recursively count the number of nodes on a level without a count parameter (Java)
body: <p>I'm looking to take some code I've written in Java for a binary tree class and remove the count parameter from the arguments, but keep the whole thing recursive.</p>
  
  <p>So, given a class with these variables:</p>
  
  <pre><code> public class BinaryTree&lt;E&gt; {
  
    protected E data;
    protected BinaryTree&lt;E&gt; left,right;
  </code></pre>
  
  <p>How could I do that for:</p>
  
  <pre><code>public int levelCount(int count, int level){
   if (data == null) {return 0;}
   if (count == level) {return 1;}
   else {
    return this.getRight().levelCount(count+1,level) + this.getLeft().levelCount(count+1,level);
    } 
  }
  </code></pre>
  
  <p>This should (and does) return the number of nodes at any given level of the binary tree.</p>
  
  <p>So with a tree "thatTree" which looks like:</p>
  
  <pre><code>     2
     /    \
    6      3
   / \    / \
  4   5  7   10 
  </code></pre>
  
  <p>thatTree.levelCount(0) returns 1, thatTree.levelCount(1) returns 2, thatTree.levelCount(2) returns 4</p>