implemented tree iterator