Figma Interview Question

bfs with tree, recursion problem