Google interview question

An N-ary tree traversal question, level leetcode medium-hard