nodes: 0, module; 1, function_definition; 2, function_name:next_pos_with_sort_not_in; 3, parameters; 4, block; 5, identifier:self; 6, identifier:address; 7, identifier:sorts; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, if_statement; 13, return_statement; 14, identifier:max_distance; 15, None; 16, comment:"""
          Returns the address of the next occupied block whose sort is not one of the specified ones.
  
          :param int address: The address to begin the search with (including itself).
          :param sorts:       A collection of sort strings.
          :param max_distance:    The maximum distance between `address` and the next position. Search will stop after
                                  we come across an occupied position that is beyond `address` + max_distance. This check
                                  will be disabled if `max_distance` is set to None.
          :return:            The next occupied position whose sort is not one of the specified ones, or None if no such
                              position exists.
          :rtype:             int or None
          """; 17, assignment; 18, assignment; 19, comparison_operator:idx < list_length; 20, comment:# Occupied; 21, block; 22, None; 23, identifier:list_length; 24, call; 25, identifier:idx; 26, call; 27, identifier:idx; 28, identifier:list_length; 29, expression_statement; 30, if_statement; 31, if_statement; 32, expression_statement; 33, while_statement; 34, identifier:len; 35, argument_list; 36, attribute; 37, argument_list; 38, assignment; 39, boolean_operator; 40, block; 41, comparison_operator:block.start <= address < block.end; 42, comment:# the address is inside the current block; 43, block; 44, assignment; 45, comparison_operator:i < list_length; 46, block; 47, attribute; 48, identifier:self; 49, identifier:_search; 50, identifier:address; 51, identifier:block; 52, subscript; 53, comparison_operator:max_distance is not None; 54, comparison_operator:address + max_distance < block.start; 55, return_statement; 56, attribute; 57, identifier:address; 58, attribute; 59, if_statement; 60, comment:# tick the idx forward by 1; 61, expression_statement; 62, identifier:i; 63, identifier:idx; 64, identifier:i; 65, identifier:list_length; 66, if_statement; 67, if_statement; 68, expression_statement; 69, identifier:self; 70, identifier:_list; 71, attribute; 72, identifier:idx; 73, identifier:max_distance; 74, None; 75, binary_operator:address + max_distance; 76, attribute; 77, None; 78, identifier:block; 79, identifier:start; 80, identifier:block; 81, identifier:end; 82, comparison_operator:block.sort not in sorts; 83, block; 84, augmented_assignment; 85, boolean_operator; 86, block; 87, comparison_operator:self._list[i].sort not in sorts; 88, block; 89, augmented_assignment; 90, identifier:self; 91, identifier:_list; 92, identifier:address; 93, identifier:max_distance; 94, identifier:block; 95, identifier:start; 96, attribute; 97, identifier:sorts; 98, return_statement; 99, identifier:idx; 100, integer:1; 101, comparison_operator:max_distance is not None; 102, comparison_operator:address + max_distance < self._list[i].start; 103, return_statement; 104, attribute; 105, identifier:sorts; 106, return_statement; 107, identifier:i; 108, integer:1; 109, identifier:block; 110, identifier:sort; 111, identifier:address; 112, identifier:max_distance; 113, None; 114, binary_operator:address + max_distance; 115, attribute; 116, None; 117, subscript; 118, identifier:sort; 119, attribute; 120, identifier:address; 121, identifier:max_distance; 122, subscript; 123, identifier:start; 124, attribute; 125, identifier:i; 126, subscript; 127, identifier:start; 128, attribute; 129, identifier:i; 130, identifier:self; 131, identifier:_list; 132, attribute; 133, identifier:i; 134, identifier:self; 135, identifier:_list; 136, identifier:self; 137, identifier:_list
code: def next_pos_with_sort_not_in(self, address, sorts, max_distance=None):
          """
          Returns the address of the next occupied block whose sort is not one of the specified ones.
  
          :param int address: The address to begin the search with (including itself).
          :param sorts:       A collection of sort strings.
          :param max_distance:    The maximum distance between `address` and the next position. Search will stop after
                                  we come across an occupied position that is beyond `address` + max_distance. This check
                                  will be disabled if `max_distance` is set to None.
          :return:            The next occupied position whose sort is not one of the specified ones, or None if no such
                              position exists.
          :rtype:             int or None
          """
  
          list_length = len(self._list)
  
          idx = self._search(address)
          if idx < list_length:
              # Occupied
              block = self._list[idx]
  
              if max_distance is not None and address + max_distance < block.start:
                  return None
  
              if block.start <= address < block.end:
                  # the address is inside the current block
                  if block.sort not in sorts:
                      return address
                  # tick the idx forward by 1
                  idx += 1
  
              i = idx
              while i < list_length:
                  if max_distance is not None and address + max_distance < self._list[i].start:
                      return None
                  if self._list[i].sort not in sorts:
                      return self._list[i].start
                  i += 1
  
          return None