Render nested tree as a HTML ordered list without using recursion