Oracle interview question

Leetcode hard, tree traversal question.