nodes: 0, module; 1, function_definition; 2, function_name:heapify; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, identifier:key; 10, identifier:__marker; 11, comment:"""
          Repair a broken heap. If the state of an item's priority value changes
          you can re-sort the relevant item only by providing ``key``.
  
          """; 12, comparison_operator:key is self.__marker; 13, block; 14, else_clause; 15, identifier:key; 16, attribute; 17, expression_statement; 18, for_statement; 19, block; 20, identifier:self; 21, identifier:__marker; 22, assignment; 23, identifier:pos; 24, call; 25, block; 26, try_statement; 27, expression_statement; 28, identifier:n; 29, call; 30, identifier:reversed; 31, argument_list; 32, expression_statement; 33, block; 34, except_clause; 35, call; 36, identifier:len; 37, argument_list; 38, call; 39, call; 40, expression_statement; 41, identifier:KeyError; 42, block; 43, attribute; 44, argument_list; 45, attribute; 46, identifier:range; 47, argument_list; 48, attribute; 49, argument_list; 50, assignment; 51, raise_statement; 52, identifier:self; 53, identifier:_reheapify; 54, identifier:pos; 55, identifier:self; 56, identifier:_heap; 57, binary_operator:n//2; 58, identifier:self; 59, identifier:_sink; 60, identifier:pos; 61, identifier:pos; 62, subscript; 63, call; 64, identifier:n; 65, integer:2; 66, attribute; 67, identifier:key; 68, identifier:KeyError; 69, argument_list; 70, identifier:self; 71, identifier:_position; 72, identifier:key
code: def heapify(self, key=__marker):
          """
          Repair a broken heap. If the state of an item's priority value changes
          you can re-sort the relevant item only by providing ``key``.
  
          """
          if key is self.__marker:
              n = len(self._heap)
              for pos in reversed(range(n//2)):
                  self._sink(pos)
          else:
              try:
                  pos = self._position[key]
              except KeyError:
                  raise KeyError(key)
              self._reheapify(pos)