Check if right sub - tree exists for the node at top If not then pop that node because we don 't need   this node any more.
if ( st [ - 1 ] . right == None ) : NEW_LINE INDENT root = st [ - 1 ] NEW_LINE st . pop ( ) NEW_LINE DEDENT