Bloomberg interview question

Create a tree iteration