def rebalance insert(selfp)pass def rebalance delete(selfp)pass def rebalance access(selfp)pass code fragment additional code for the treemap class (continued from code fragment )providing stubs for the rebalancing hooks nonpublic methods for rotating and restructuring second form of support for balanced search trees is our inclusion of nonpublic utility methods rotate and restructure thatrespectivelyimplement single rotation and trinode restructuring (described at the beginning of section although these methods are not invoked by the public treemap operationswe promote code reuse by providing these implementation in this class so that they are inherited by all balanced-tree subclasses our implementations are provided in code fragment to simplify the codewe define an additional relink utility that properly links parent and child nodes to each otherincluding the special case in which "childis none reference the focus of the rotate method then becomes redefining the relationship between the parent and childrelinking rotated node directly to its original grandparentand shifting the "middlesubtree (that labeled as in figure between the rotated nodes for the trinode restructuringwe determine whether to perform single or double rotationas originally described in figure factory for creating tree nodes we draw attention to an important subtlety in the design of both our treemap class and the original linkedbinarytree subclass the low-level definition of node is provided by the nested node class within linkedbinarytree yetseveral of our tree-balancing strategies require that auxiliary information be stored at each node to guide the balancing process those classes will override the nested node class to provide storage for an additional field whenever we add new node to the treeas within the add right method of the linkedbinarytree (originally given in code fragment )we intentionally instantiate the node using the syntax self noderather than the qualified name linkedbinarytree node this is vital to our frameworkwhen the expression self node is applied to an instance of tree (sub)classpython' name resolution follows the inheritance structure (as described in section if subclass has overridden the definition for the node classinstantiation of self node relies on the newly defined node class this technique is an example of the factory method design patternas we provide subclass the means to control the type of node that is created within methods of the parent class