def __repr__(self)return '*def lookup(selfkey)return none def insert(selfkeyval)return binarynode(selfkeyvalselffail at the bottom add node at bottom class binarynodedef __init__(selfleftkeyvalright)self keyself val keyval self leftself right leftright def lookup(selfkey)if self key =keyreturn self val elif self key keyreturn self left lookup(keyelsereturn self right lookup(keydef insert(selfkeyval)if self key =keyself val val elif self key keyself left self left insert(keyvalelif self key keyself right self right insert(keyvalreturn self look in left look in right grow in left grow in right def __repr__(self)return ('% % =% % )(repr(self left)repr(self key)repr(self val)repr(self right))if __name__ ='__main__' keyedbinarytree(for (keyvalin [('bbb' )('aaa' )('ccc' )] insert(keyvalprint(tprint( lookup('aaa') lookup('ccc') insert('ddd' insert('aaa' changes key' value print(tthe following shows this script' self-test code at worknodes simply have more content this time aroundc:\pp \dstruct\classicspython btreevals py *'aaa'= )'bbb'= *'ccc'= *'aaa'= )'bbb'= *'ccc'= *'ddd'= in factthe effect is similar to the keys and values of built-in dictionarybut custom tree structure like this might support custom use cases and algorithmsas well as code binary search trees