So messy, but got the tree structure working