Refactor navigation tree to use a recursive template.