code: def __get_search_results(self, url, limit, order_by, sort_order, filter):
          order_by_options = ['search_rank', 'series_id', 'title', 'units', 'frequency',
                              'seasonal_adjustment', 'realtime_start', 'realtime_end', 'last_updated',
                              'observation_start', 'observation_end', 'popularity']
          if order_by is not None:
              if order_by in order_by_options:
                  url = url + '&order_by=' + order_by
              else:
                  raise ValueError('%s is not in the valid list of order_by options: %s' % (order_by, str(order_by_options)))
          if filter is not None:
              if len(filter) == 2:
                  url = url + '&filter_variable=%s&filter_value=%s' % (filter[0], filter[1])
              else:
                  raise ValueError('Filter should be a 2 item tuple like (filter_variable, filter_value)')
          sort_order_options = ['asc', 'desc']
          if sort_order is not None:
              if sort_order in sort_order_options:
                  url = url + '&sort_order=' + sort_order
              else:
                  raise ValueError('%s is not in the valid list of sort_order options: %s' % (sort_order, str(sort_order_options)))
          data, num_results_total = self.__do_series_search(url)
          if data is None:
              return data
          if limit == 0:
              max_results_needed = num_results_total
          else:
              max_results_needed = limit
          if max_results_needed > self.max_results_per_request:
              for i in range(1, max_results_needed // self.max_results_per_request + 1):
                  offset = i * self.max_results_per_request
                  next_data, _ = self.__do_series_search(url + '&offset=' + str(offset))
                  data = data.append(next_data)
          return data.head(max_results_needed)