def METHOD_NAME(url, params=None, headers=None,
                          max_count=None, stop_if=None):
    # get first page
    if args.verbose:
        print('fetching {}...'.format(url))
    r = requests.get(url, params=params, headers=headers)
    assert r.status_code == 200
    if args.verbose and ('RateLimit-Remaining' in r.headers):
        print('rate limit: {} (reset at {})'.format(r.headers['RateLimit-Remaining'],
                                                    r.headers['RateLimit-ResetTime']))
    data = r.json()
    while 'next' in r.links:
        if stop_if and stop_if(data):
            break
        if max_count and (len(data) >= max_count):
            break
        if args.delay:
            time.sleep(args.delay)
        # params are already encoded in next link
        if args.verbose:
            print('fetching {}...'.format(r.links['next']['url']))
        r = requests.get(r.links['next']['url'], headers=headers)
        assert r.status_code == 200
        data.extend(r.json())
    return data