M2M Services interview question

Recursion with backtrack on different structures