SPS Commerce interview question

Similar to traversing through a tree