nodes: 0, module; 1, function_definition; 2, function_name:find; 3, parameters; 4, block; 5, identifier:self; 6, identifier:term; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, if_statement; 15, if_statement; 16, return_statement; 17, identifier:limit; 18, integer:0; 19, identifier:sort; 20, False; 21, identifier:ranks; 22, None; 23, comment:"""
          Searches the stack for cards with a value, suit, name, or
          abbreviation matching the given argument, 'term'.
  
          :arg str term:
              The search term. Can be a card full name, value, suit,
              or abbreviation.
          :arg int limit:
              The number of items to retrieve for each term. ``0`` equals
              no limit.
          :arg bool sort:
              Whether or not to sort the results.
          :arg dict ranks:
              The rank dict to reference for sorting. If ``None``, it will
              default to ``DEFAULT_RANKS``.
  
          :returns:
              A list of stack indices for the cards matching the given terms,
              if found.
  
          """; 24, assignment; 25, assignment; 26, assignment; 27, not_operator; 28, block; 29, else_clause; 30, identifier:sort; 31, block; 32, identifier:found_indices; 33, identifier:ranks; 34, boolean_operator; 35, identifier:found_indices; 36, list; 37, identifier:count; 38, integer:0; 39, identifier:limit; 40, for_statement; 41, block; 42, expression_statement; 43, identifier:ranks; 44, attribute; 45, pattern_list; 46, call; 47, block; 48, for_statement; 49, assignment; 50, identifier:self; 51, identifier:ranks; 52, identifier:i; 53, identifier:card; 54, identifier:enumerate; 55, argument_list; 56, if_statement; 57, pattern_list; 58, call; 59, block; 60, identifier:found_indices; 61, call; 62, attribute; 63, call; 64, block; 65, identifier:i; 66, identifier:card; 67, identifier:enumerate; 68, argument_list; 69, if_statement; 70, identifier:sort_card_indices; 71, argument_list; 72, identifier:self; 73, identifier:cards; 74, identifier:check_term; 75, argument_list; 76, expression_statement; 77, attribute; 78, comparison_operator:count < limit; 79, block; 80, else_clause; 81, identifier:self; 82, identifier:found_indices; 83, identifier:ranks; 84, identifier:card; 85, identifier:term; 86, call; 87, identifier:self; 88, identifier:cards; 89, identifier:count; 90, identifier:limit; 91, if_statement; 92, block; 93, attribute; 94, argument_list; 95, call; 96, block; 97, break_statement; 98, identifier:found_indices; 99, identifier:append; 100, identifier:i; 101, identifier:check_term; 102, argument_list; 103, expression_statement; 104, expression_statement; 105, identifier:card; 106, identifier:term; 107, call; 108, augmented_assignment; 109, attribute; 110, argument_list; 111, identifier:count; 112, integer:1; 113, identifier:found_indices; 114, identifier:append; 115, identifier:i
code: def find(self, term, limit=0, sort=False, ranks=None):
          """
          Searches the stack for cards with a value, suit, name, or
          abbreviation matching the given argument, 'term'.
  
          :arg str term:
              The search term. Can be a card full name, value, suit,
              or abbreviation.
          :arg int limit:
              The number of items to retrieve for each term. ``0`` equals
              no limit.
          :arg bool sort:
              Whether or not to sort the results.
          :arg dict ranks:
              The rank dict to reference for sorting. If ``None``, it will
              default to ``DEFAULT_RANKS``.
  
          :returns:
              A list of stack indices for the cards matching the given terms,
              if found.
  
          """
          ranks = ranks or self.ranks
          found_indices = []
          count = 0
  
          if not limit:
              for i, card in enumerate(self.cards):
                  if check_term(card, term):
                      found_indices.append(i)
          else:
              for i, card in enumerate(self.cards):
                  if count < limit:
                      if check_term(card, term):
                          found_indices.append(i)
                          count += 1
                  else:
                      break
  
          if sort:
              found_indices = sort_card_indices(self, found_indices, ranks)
  
          return found_indices