M2M Services Interview Question

Recursion with backtrack on different structures