Slync interview question

How to solve a recursive DOM algorithm.