nodes: 0, module; 1, function_definition; 2, function_name:_cursor; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, dictionary_splat_pattern; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, expression_statement; 15, if_statement; 16, expression_statement; 17, return_statement; 18, identifier:offset; 19, integer:0; 20, identifier:limit; 21, integer:0; 22, identifier:fields; 23, None; 24, identifier:sort; 25, None; 26, identifier:kwargs; 27, comment:"""Return a cursor on a filtered list of documents in a collection.
  
          :param offset: for pagination, which record to start attribute
          :param limit: for pagination, how many records to return
          :param fields: list of field names to return (otherwise returns all)
          :param sort: list of fields to sort by (prefix with '-' for descending)
          :param kwargs: key/values to find (only supports equality for now)
  
          :returns: a tuple of a cursor on documents and the total count
  
          Note: close the cursor after using it if you don't exhaust it
          """; 28, assignment; 29, identifier:fields; 30, block; 31, assignment; 32, identifier:sort; 33, block; 34, call; 35, identifier:results; 36, identifier:projection; 37, dictionary; 38, expression_statement; 39, identifier:results; 40, call; 41, expression_statement; 42, for_statement; 43, expression_statement; 44, attribute; 45, argument_list; 46, pair; 47, call; 48, attribute; 49, argument_list; 50, assignment; 51, pattern_list; 52, call; 53, block; 54, call; 55, call; 56, identifier:limit; 57, boolean_operator; 58, string; 59, False; 60, attribute; 61, argument_list; 62, attribute; 63, identifier:find; 64, identifier:kwargs; 65, identifier:projection; 66, identifier:sort_pairs; 67, subscript; 68, identifier:index; 69, identifier:field; 70, identifier:enumerate; 71, argument_list; 72, if_statement; 73, attribute; 74, argument_list; 75, attribute; 76, argument_list; 77, identifier:limit; 78, integer:0; 79, string_content:_id; 80, identifier:projection; 81, identifier:update; 82, dictionary_comprehension; 83, identifier:self; 84, identifier:_collection; 85, identifier:sort; 86, slice; 87, identifier:sort; 88, comparison_operator:field[0] == "-"; 89, block; 90, else_clause; 91, identifier:results; 92, identifier:sort; 93, identifier:sort_pairs; 94, identifier:results; 95, identifier:skip; 96, boolean_operator; 97, pair; 98, for_in_clause; 99, subscript; 100, string:"-"; 101, expression_statement; 102, block; 103, identifier:offset; 104, integer:0; 105, identifier:field; 106, True; 107, identifier:field; 108, identifier:fields; 109, identifier:field; 110, integer:0; 111, assignment; 112, expression_statement; 113, subscript; 114, tuple; 115, assignment; 116, identifier:sort_pairs; 117, identifier:index; 118, subscript; 119, attribute; 120, subscript; 121, tuple; 122, identifier:field; 123, slice; 124, identifier:pymongo; 125, identifier:DESCENDING; 126, identifier:sort_pairs; 127, identifier:index; 128, identifier:field; 129, attribute; 130, integer:1; 131, identifier:pymongo; 132, identifier:ASCENDING
code: def _cursor(self, offset=0, limit=0, fields=None, sort=None, **kwargs):
          """Return a cursor on a filtered list of documents in a collection.
  
          :param offset: for pagination, which record to start attribute
          :param limit: for pagination, how many records to return
          :param fields: list of field names to return (otherwise returns all)
          :param sort: list of fields to sort by (prefix with '-' for descending)
          :param kwargs: key/values to find (only supports equality for now)
  
          :returns: a tuple of a cursor on documents and the total count
  
          Note: close the cursor after using it if you don't exhaust it
          """
          projection = {'_id': False}
          if fields:
              projection.update({field: True for field in fields})
          results = self._collection.find(kwargs, projection)
          if sort:
              sort_pairs = sort[:]
              for index, field in enumerate(sort):
                  if field[0] == "-":
                      sort_pairs[index] = (field[1:], pymongo.DESCENDING)
                  else:
                      sort_pairs[index] = (field, pymongo.ASCENDING)
              results.sort(sort_pairs)
          results.skip(offset or 0).limit(limit or 0)
          return results