Refine the traverse algorithms for Tree