once the tree is constructedthe next task is to implement the retrieval of value for given key the get method is even easier than the put method because it simply searches the tree recursively until it gets to non-matching leaf node or finds matching key when matching key is foundthe value stored in the payload of the node is returned below we show the code for get_get and __getitem__ the search code in the _get method uses the same logic for choosing the left or right child as the _put method notice that the _get method returns treenode to getthis allows _get to be used as flexible helper method for other binarysearchtree methods that may need to make use of other data from the treenode besides the payload by implementing the __getitem__ method we can write python statement that looks just like we are accessing dictionarywhen in fact we are using binary search treefor example my_zip_tree['fargo'as you can seeall the__getitem__ method does is call get def get(self,key)if self rootres self _get(keyself rootif resreturn res payload elsereturn none elsereturn none def _get(selfkeycurrent_node)if not current_nodereturn none elif current_node key =keyreturn current_node trees and tree algorithms