def get_paginated_generator(api_client):
    """This generator can be used to get() paginated results

    If 'api_client' is a Slumber resource, you can use this generator
    as so:

      for doc in get_paginated_generator(api_client):
          pass

    and if the remote PopIt instance returns paginated results, it
    will return all them, whereas the following:

      for doc in api_client.get()['result']:
          pass

    ... would only return the first page."""
    page = 1
    keep_fetching = True
    while keep_fetching:
        response = api_client.get(per_page=50, page=page)
        keep_fetching = response.get('has_more', False)
        page += 1
        for doc in response['result']:
            yield doc
