using System.Collections.Generic;
static Node<string> root = new Node<string> ("Root")
Left = new Node<string>("Left of root") {
Left = new Node<string>("TEST"),
Right = new Node<string>("ABCDEF")
Right = new Node<string>("Right of root")
public static void Main()
bool contains_TEST = Contains<string>("TEST", root);
Console.WriteLine("Root contains 'TEST'");
Console.WriteLine("Root does NOT contain 'TEST'");
bool contains_NOTHING = Contains<string>("NOTHING", root);
Console.WriteLine("Root contains 'NOTHING'");
Console.WriteLine("Root does NOT contain 'NOTHING'");
static bool Contains<T>(T item, Node<T> tree) {
Stack<Node<T>> stack = new Stack<Node<T>>();
if (item.Equals(current.Data))
Console.WriteLine("Found");
if(current.Left != null) stack.Push(current.Left);
if(current.Right != null) stack.Push(current.Right);
} while(stack.Count > 0);
public int balanceFactor;