docs: def get_tweets_count_times(twitter, count, query=None):
      r""" hits the twitter api `count` times and grabs tweets for the indicated query"""
      # get id to start from
      oldest_id, newest_id = _get_oldest_id(query=query)
      newest_id = newest_id or oldest_id
  
      all_tweets = []
      i = 0
      while i < count:
          i += 1
          # use search api to request 100 tweets. Twitter returns the most recent (max_id) first
          if oldest_id <= newest_id:
              tweets = get_tweets(query=query, max_id=oldest_id - 1, count=TWEETS_PER_SEARCH, twitter=twitter)
          else:
              tweets = get_tweets(query=query, max_id=oldest_id - 1, since_id=newest_id, count=TWEETS_PER_SEARCH, twitter=twitter)
          rate_limit_remaining = twitter.get_lastfunction_header('x-rate-limit-remaining')
          rate_limit_reset = twitter.get_lastfunction_header('x-rate-limit-reset')
  
          if not len(tweets):
              # not rate limitted, just no tweets returned by query
              oldest_id = oldest_id + ((newest_id or oldest_id) - oldest_id + 1) * 10000
              break
          elif isinstance(tweets, dict):
              # rate limit hit, or other twython response error
              print(tweets)
              break
  
          all_tweets.extend(tweets)
  
          # determine new oldest id
          tweet_ids = {t['id'] for t in tweets}
          if oldest_id:
              tweet_ids.add(oldest_id)
          oldest_id, newest_id = min(tweet_ids), max(tweet_ids)
          if rate_limit_remaining == 1:
              time.sleep(rate_limit_reset - time.time())
  
      save_tweets(all_tweets, query=query)
  
      # set id to start from for next time
      _set_oldest_id(oldest_id, newest_id, query=query)
  
      if len(all_tweets) == 0:
          os.remove(make_oldest_id_path(query))
  
      return len(all_tweets), twitter.get_lastfunction_header('x-rate-limit-remaining')