fix a bug in treeToList