pouring most of the treegenerator.py rules into this
more rewrite of py code