nodes: 0, module; 1, function_definition; 2, function_name:_get_fields; 3, parameters; 4, block; 5, identifier:attrs; 6, identifier:field_class; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, if_statement; 13, return_statement; 14, identifier:pop; 15, False; 16, identifier:ordered; 17, False; 18, comment:"""Get fields from a class. If ordered=True, fields will sorted by creation index.
  
      :param attrs: Mapping of class attributes
      :param type field_class: Base field class
      :param bool pop: Remove matching fields
      """; 19, assignment; 20, identifier:pop; 21, block; 22, identifier:ordered; 23, block; 24, identifier:fields; 25, identifier:fields; 26, list_comprehension; 27, for_statement; 28, expression_statement; 29, tuple; 30, for_in_clause; 31, if_clause; 32, pattern_list; 33, identifier:fields; 34, block; 35, call; 36, identifier:field_name; 37, identifier:field_value; 38, pattern_list; 39, call; 40, call; 41, identifier:field_name; 42, identifier:_; 43, delete_statement; 44, attribute; 45, argument_list; 46, identifier:field_name; 47, identifier:field_value; 48, identifier:iteritems; 49, argument_list; 50, identifier:is_instance_or_subclass; 51, argument_list; 52, subscript; 53, identifier:fields; 54, identifier:sort; 55, keyword_argument; 56, identifier:attrs; 57, identifier:field_value; 58, identifier:field_class; 59, identifier:attrs; 60, identifier:field_name; 61, identifier:key; 62, lambda; 63, lambda_parameters; 64, attribute; 65, identifier:pair; 66, subscript; 67, identifier:_creation_index; 68, identifier:pair; 69, integer:1
code: def _get_fields(attrs, field_class, pop=False, ordered=False):
      """Get fields from a class. If ordered=True, fields will sorted by creation index.
  
      :param attrs: Mapping of class attributes
      :param type field_class: Base field class
      :param bool pop: Remove matching fields
      """
      fields = [
          (field_name, field_value)
          for field_name, field_value in iteritems(attrs)
          if is_instance_or_subclass(field_value, field_class)
      ]
      if pop:
          for field_name, _ in fields:
              del attrs[field_name]
      if ordered:
          fields.sort(key=lambda pair: pair[1]._creation_index)
      return fields