traverse until the queue is empty
while ( len ( q ) ) : NEW_LINE INDENT temp = q [ 0 ] NEW_LINE q . pop ( 0 ) NEW_LINE if ( temp . left ) : NEW_LINE INDENT q . append ( temp . left ) NEW_LINE if ( not temp . left . left and not temp . left . right ) : NEW_LINE INDENT result = temp . left NEW_LINE DEDENT DEDENT DEDENT