title: Find child in a java Tree(recursively)
body: <p>thanks for check it out. What I want is to get the tree where root id is the id passed by param but its returning null pointer.</p>
  
  <p>Tree settings</p>
  
  <pre><code>TreeIF&lt;DoctorIF&gt; tree = new Tree&lt;DoctorIF&gt;();
  
     setTree(tree);
  
     DoctorS ceo = new DoctorS(1, this);
     DoctorS two = new DoctorS(2, this);
     DoctorS three = new DoctorS(3, this);
     DoctorS four = new DoctorS(4, this);
     DoctorS five = new DoctorS(5, this);
     DoctorS six = new DoctorS(6, this);
     DoctorS seven = new DoctorS(7, this);
  
     TreeIF&lt;DoctorIF&gt; t1 = new Tree&lt;DoctorIF&gt;(three);
     TreeIF&lt;DoctorIF&gt; t2 = new Tree&lt;DoctorIF&gt;(four);
     TreeIF&lt;DoctorIF&gt; t3 = new Tree&lt;DoctorIF&gt;(two);
     tree.setRoot(ceo);
  
     t1.addChild(new Tree&lt;DoctorIF&gt;(seven));
     t2.addChild(new Tree&lt;DoctorIF&gt;(five));
     t3.addChild(t1);
     t3.addChild(t2);
     t3.addChild(new Tree&lt;DoctorIF&gt;(six));
  
     tree.addChild(t3);
  </code></pre>
  
  <p>Function to get tree or tree child. I got nullpointer when I'm searching id {4,5,6,7}. </p>
  
  <pre><code>private TreeIF&lt;DoctorIF&gt; getTreeChild(TreeIF&lt;DoctorIF&gt; tree_, int id){
      if (tree_.getRoot().getId()==id &amp;&amp; id!=1)return tree_;
      else{
          ListIF&lt;TreeIF&lt;DoctorIF&gt;&gt; list = tree_.getChildren();
          IteratorIF&lt;TreeIF&lt;DoctorIF&gt;&gt; it = list.getIterator();
          while(it.hasNext()){
              TreeIF&lt;DoctorIF&gt; subtree = getTreeChild(it.getNext(), id);
              if (subtree.getRoot()!=null &amp;&amp; subtree.getRoot().getId()==id)return subtree;
          }
      }
      return null;
  }
  
   @Override
  public DoctorIF getDoctor(int id){
      TreeIF&lt;DoctorIF&gt; tree_ = null;
      tree_ = getTreeChild(tree, id);
      return tree_.getRoot();
  }
  </code></pre>