implement Tree.tsort