def iterate(collection_name, batch_size=5000, cursor=None):
query = client.collection(collection_name).limit(batch_size).order_by('__name__')
if cursor:
query = query.start_after(cursor)
for doc in query.stream():
yield doc
if 'doc' in locals():
yield from iterate(collection_name, batch_size, doc)