preorder visit to tree nodes