If the key is equal to the root then simply return 0 ( zero 'th level)
if ( data == root . data ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT cur_level = 0 NEW_LINE while True : NEW_LINE INDENT cur_level += 1 NEW_LINE root = root . left NEW_LINE DEDENT