Verily interview question

recursion / iteration, tree, design question