title: How to return nothing from a function that returning value?
body: <p>I have a binary search tree, and I want to delete a node.</p>
  
  <p>I need to get its parent, so I wrote a function:</p>
  
  <pre><code>private BSTreeNode&lt;T&gt; getParent(BSTreeNode&lt;T&gt; root, BSTreeNode&lt;T&gt; node) {
          if(root == null) 
              return null;
          if(node.element().lessThan(root.element())) {
              if(root.getLeft() != null &amp;&amp; root.getLeft().element().equal(node.element())) 
                  return root;
              else
                  getParent(root.getLeft(), node);
          } else {
              if(root.getRight() != null &amp;&amp; root.getRight().element().equal(node.element()))
                  return root;
              else
                  getParent(root.getRight(), node);
          }
      }
  </code></pre>
  
  <p>Unlike C/C++, Java is giving me the following error:</p>
  
  <pre><code>This method must return a result of type BSTreeNode&lt;T&gt;
  </code></pre>
  
  <p>It forces me to return a value in the last line of the function.</p>
  
  <p>How can I fix it in the context of my function? </p>