I honestly don't see much the value of generators here. we can simply return all the results directly from the xpath function that you created. Are there any use case where you would want to stream the elements one by one ? you have got all the results in memory anyways inside the xpath function