class treemap(linkedbinarytreemapbase) """sorted map implementation using binary search tree "" override position class class position(linkedbinarytree position) def key(self) """return key of map key-value pair "" return self elementkey def value(self) """return value of map key-value pair "" return self elementvalue nonpublic utilities def subtree search(selfpk) """return position of subtree having key kor last node searched "" if = key)found match return elif key)search left subtree if self left(pis not none return self subtree search(self left( ) elsesearch right subtree if self right(pis not none return self subtree search(self right( ) return unsucessful search def subtree first position(selfp) """return position of first item in subtree rooted at "" walk while self left(walkis not nonekeep walking left walk self left(walk return walk def subtree last position(selfp) """return position of last item in subtree rooted at "" walk while self right(walkis not nonekeep walking right walk self right(walk return walk code fragment beginning of treemap class based on binary search tree