rendered paste body public int getElementCount() { if(root == null) { return 0; } else if(root != null && root.left == null && root.right == null) { return 1; } else { return getElementCount(root.left)+getElementCount(root.right)+1; } } public int getElementCount(Node currentNode) { int count=0; if(currentNode != null && currentNode.left != null) { getElementCount(currentNode.left); count++; } if(currentNode != null && currentNode.right != null) { getElementCount(currentNode.right); count++; } return count; }