messing with cleaner ways of building the tree involving less casting and more generics