finished treeify, solver code