updated treeFor function to old style