Google Interview Question

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