tree recursion to remove temporal nodes