title: Searching all nodes of a binary tree in Java
body: <p>I am trying to write a method to search all nodes of a binary tree for a passed value and return the node when found. I cannot seem to get the logic right to search both sides of the tree. Here is what I have so far.</p>
  
  <pre><code>private Node locate(String p, Node famTree)
  {  
      if (root == null)//If tree empty return null;
          return null;
      if (famTree.value.equals(p)) //If leaf contains the passed parent value the boolean becomes true.
          return famTree;
      if (famTree.left != null)
          return locate(p,famTree.left);
      else
          return locate(p,famTree.right);
  
  }
  </code></pre>