Fixed some bugs in treeAtPath