Intel Corporation Interview Question

traversing tree python code, data structure code