implemented a second version of the inorder next node algorithm