Figma interview question

bfs with tree, recursion problem