title: Binary Tree getParent Function
body: <p>I have implemented this function that searches recursively from a node and returns a node that has a child with some given node data, if found, 0 otherwise.</p>
  
  <pre><code>Node&lt;T&gt; * BinaryTree&lt;T&gt;::searchParent ( T key , Node&lt;T&gt; * p ) const
  {
      if ( p == 0 )
          return 0;
  
      if ( p-&gt;left &amp;&amp; p-&gt;left-&gt;info == key )
          return p;
      else if ( p-&gt;right &amp;&amp; p-&gt;right-&gt;info == key  )
          return p;
  
      Node&lt;T&gt; * q = searchParent ( key , p-&gt;left );
  
      if ( q == 0 )
          return searchParent ( key , p-&gt;right );
  
      return q;
  }
  </code></pre>
  
  <p>Now I want to implement this function that finds and returns the data of the parent of a given node, if only the node data is given.</p>
  
  <pre><code>T BinaryTree&lt;T&gt;::getParent( T node )
  </code></pre>
  
  <p>But I am not able to implement this recursively or non recursively.</p>