public IEnumerator PreOrderTraversal()
{
if (Head != null)
{
Stack> stack = new Stack>();
BinaryTreeNode current = Head;
stack.Push(null);
while (stack.Count!=0)
{
if (current != null)
{
yield return current.Value;
if (current.Right != null)
stack.Push(current.Right);
if (current.Left != null)
{
current = current.Left;
}
else
{
current = stack.Pop();
}
}
}
}
}
{
if (Head != null)
{
Stack
BinaryTreeNode
stack.Push(null);
while (stack.Count!=0)
{
if (current != null)
{
yield return current.Value;
if (current.Right != null)
stack.Push(current.Right);
if (current.Left != null)
{
current = current.Left;
}
else
{
current = stack.Pop();
}
}
}
}
}