typed the function to iteratePostOrder