#NEWLINE# def recurse_bst( node , lastkey ) : #NEWLINE# #INDENT# char = None #NEWLINE# if ( node is None ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# offset = ( node . key / 2 ) #NEWLINE# if ( lastkey is None ) : #NEWLINE# #INDENT# char = '|' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( lastkey > node . key ) : #NEWLINE# #INDENT# char = ' /' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# char = '\\' #NEWLINE# #UNINDENT# #UNINDENT# if ( lastkey is not None ) : #NEWLINE# #INDENT# diff = ( abs ( ( lastkey - node . key ) ) / 2 ) #NEWLINE# connector = ( '.' * diff ) #NEWLINE# if ( diff > 2 ) : #NEWLINE# #INDENT# if ( lastkey < node . key ) : #NEWLINE# #INDENT# print ( '{} {}' . format ( '' . ljust ( ( offset - diff ) ) , connector ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( '{} {}' . format ( '' . ljust ( ( ( offset - ( diff / 8 ) ) + 2 ) ) , connector ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# print ( '{} {}' . format ( '' . ljust ( offset ) , char ) ) #NEWLINE# print ( '{} {}' . format ( '' . ljust ( offset ) , node . key ) ) #NEWLINE# if ( node . left_child is not None ) : #NEWLINE# #INDENT# recurse_bst ( node . left_child , node . key ) #NEWLINE# #UNINDENT# if ( node . right_child is not None ) : #NEWLINE# #INDENT# recurse_bst ( node . right_child , node . key )