public void Add(int newNodeValue) { Node newNode = new Node(newNodeValue); if (head == null) { head = newNode; return; } Node currentNode = head; while (currentNode.GetLeftChild() != null || currentNode.GetRightChild() != null) { if (newNodeValue > currentNode.GetValue()) { if (currentNode.GetRightChild() != null) { currentNode = currentNode.GetRightChild(); } else { break; } } else if (newNodeValue < currentNode.GetValue()) { if (currentNode.GetLeftChild() != null) { currentNode = currentNode.GetLeftChild(); } else { break; } } else { Console.WriteLine("The Node already exists"); return; } } if (newNodeValue > currentNode.GetValue()) { currentNode.SetRightChild(newNode); } else { currentNode.SetLeftChild(newNode); } }