tree traversing algorithme