SPS Commerce Interview Question

Similar to traversing through a tree