title: Recursive search through tree without passing object
body: <p>I'm trying to search for a node in a non-binary tree without actually passing a node to the search method. </p>
  
  <p>Each node has a <code>name</code> variable. The <code>findChild()</code> method takes a name, and searches through the tree it was called on to find the node with that name.</p>
  
  <p>To do the recursive search, I call <code>findChild()</code> on the child node rather than passing the child node to the <code>findChild()</code> method. Print statements show me that the method gets down through the tree, but the <code>result</code> variable gets set to null as the stack is unwinded, so the method always returns null. I understand why it's doing this, but I don't understand how to unwind this type of recursion. Any help is appreciated!</p>
  
  <p>My <code>findChild()</code> method:</p>
  
  <pre><code>public FileNode findChild(String name) {
      FileNode result = null;
          for (FileNode child : this.getChildren()) {
              if (child.getName() == name) {
                  return child;
              } else {
                  child.findChild(name);
              }
          }
      return result;
  }
  </code></pre>