Slync Interview Question

How to solve a recursive DOM algorithm.