WIP: first pass on tree.py