TSTree_traverse implementation