Sigma Computing Interview Question

It was a tree traversal problem.