Non-recursive algorithm program for traversing binary trees in preorder