Functional programming for the walk-inorder function