change output to handle any tree content, makes it easier to extend stuff

the parser also creates elements using a simple push and pop approach