add while method to travller the tree