static void TestGetNodePath() { TreeNode<int> root; root = Utility.CreateBinarySearchTree(); TreeNode<int> node = root.LeftNode.RightNode; Console.WriteLine("candidate node is " + node.Value); if (node != null) { Stack<int> stack = new Stack<int>(); Boolean hasNode = Utility.GetNodePath(root, node, stack); if (hasNode) { Console.WriteLine(String.Join(" ", stack.Select(n => n.ToString()).ToArray())); } else { Console.WriteLine("Not contain the node"); } } else { Console.WriteLine("the node is null"); } }