<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _fetch_pages(self, item_type, items_key, request_path, startAt=0, maxResults=50, params=None, base=JIRA_BASE_URL, ):
 """Fetch pages. :param item_type: Type of single item. ResultList of such items will be returned. :type item_type: type :param items_key: Path to the items in JSON returned from server. Set it to None, if response is an array, and not a JSON object. :type items_key: Optional[str] :param request_path: path in request URL :type request_path: str :param startAt: index of the first record to be fetched. (Default: 0) :type startAt: int :param maxResults: Maximum number of items to return. If maxResults evaluates as False, it will try to get all items in batches. (Default:50) :type maxResults: int :param params: Params to be used in all requests. Should not contain startAt and maxResults, as they will be added for each request created from this function. :type params: Dict[str, Any] :param base: base URL :type base: str :rtype: ResultList """

        async_class = None
        if self._options['async']:
            try:
                from requests_futures.sessions import FuturesSession
                async_class = FuturesSession
            except ImportError:
                pass
            async_workers = self._options['async_workers']
        page_params = params.copy() if params else {}
        if startAt:
            page_params['startAt'] = startAt
        if maxResults:
            page_params['maxResults'] = maxResults

        resource = self._get_json(request_path, params=page_params, base=base)
        next_items_page = self._get_items_from_page(item_type, items_key,
                                                    resource)
        items = next_items_page

        if True:  # isinstance(resource, dict):

            if isinstance(resource, dict):
                total = resource.get('total')
                # 'isLast' is the optional key added to responses in JIRA Agile 6.7.6. So far not used in basic JIRA API.
                is_last = resource.get('isLast', False)
                start_at_from_response = resource.get('startAt', 0)
                max_results_from_response = resource.get('maxResults', 1)
            else:
                # if is a list
                total = 1
                is_last = True
                start_at_from_response = 0
                max_results_from_response = 1

            # If maxResults evaluates as False, get all items in batches
            if not maxResults:
                page_size = max_results_from_response or len(items)
                page_start = (startAt or start_at_from_response or 0) + page_size
                if async_class is not None and not is_last and (
                        total is not None and len(items) < total):
                    async_fetches = []
                    future_session = async_class(session=self._session, max_workers=async_workers)
                    for start_index in range(page_start, total, page_size):
                        page_params = params.copy()
                        page_params['startAt'] = start_index
                        page_params['maxResults'] = page_size
                        url = self._get_url(request_path)
                        r = future_session.get(url, params=page_params)
                        async_fetches.append(r)
                    for future in async_fetches:
                        response = future.result()
                        resource = json_loads(response)
                        if resource:
                            next_items_page = self._get_items_from_page(
                                item_type, items_key, resource)
                            items.extend(next_items_page)
                while async_class is None and not is_last and (
                    total is None or page_start < total) and len(
                        next_items_page) == page_size:
                    page_params['startAt'] = page_start
                    page_params['maxResults'] = page_size
                    resource = self._get_json(request_path, params=page_params, base=base)
                    if resource:
                        next_items_page = self._get_items_from_page(
                            item_type, items_key, resource)
                        items.extend(next_items_page)
                        page_start += page_size
                    else:
                        # if resource is an empty dictionary we assume no-results
                        break

            return ResultList(items, start_at_from_response, max_results_from_response, total, is_last)
        else:
            # it seams that search_users can return a list() containing a single user!
            return ResultList([item_type(self._options, self._session, resource)], 0, 1, 1, True)