title: Question on binary search tree
body: <p>I am looking at the following code: <a href="http://netrsc.blogspot.com/2010/04/net-c-binary-tree.html" rel="nofollow">http://netrsc.blogspot.com/2010/04/net-c-binary-tree.html</a></p>
  
  <p>Am I right in thinking that the <code>while (!Found)</code> condition will iterate the tree?</p>
  
  <pre><code>protected void Insert(T item)
  {
      TreeNode&lt;T&gt; TempNode = Root;
      bool Found=false;
      while (!Found)
      {
          int ComparedValue = TempNode.Value.CompareTo(item);
          if(ComparedValue&lt;0)
          {
              if(TempNode.Left==null)
              {
                  TempNode.Left=new TreeNode&lt;T&gt;(item,TempNode);
                  ++NumberOfNodes;
                  return;
              }
              else
              {
                  TempNode=TempNode.Left;
              }
          }
          else if(ComparedValue&gt;0)
          {
              if(TempNode.Right==null)
              {
                  TempNode.Right=new TreeNode&lt;T&gt;(item,TempNode);
                  ++NumberOfNodes;
                  return;
              }
              else
              {
                  TempNode=TempNode.Right;
              }
          }
          else
          {
              TempNode=TempNode.Right;
          }
      }
  }
  </code></pre>
  
  <p>Also, for the find and traversal methods, how do these work? If nothing is returned from the Traversal method but from the left branch, would the loop in Find execute again? How would it know to execute down the right branch?</p>
  
  <pre><code>protected IEnumerable&lt;TreeNode&lt;T&gt;&gt; Traversal(TreeNode&lt;T&gt; Node)
  {
      if (Node.Left != null)
      {
          foreach (TreeNode&lt;T&gt; LeftNode in Traversal(Node.Left))
              yield return LeftNode;
      }
      yield return Node;
      if (Node.Right != null)
      {
          foreach (TreeNode&lt;T&gt; RightNode in Traversal(Node.Right))
              yield return RightNode;
      }
  }
  </code></pre>
  
  <p>Thanks</p>