Create Tree Menu for Accordion Development

I'm working on a collapsing/accordion menu.  Here is the precursor to the php generator. Whereby the pages with children are separated from those without. sub-branches from terminal-branches