append right & left children of the popped node to stack . Also set their parent pointer in the map
if ( current . right ) : NEW_LINE INDENT parent [ current . right ] = current NEW_LINE nodeStack . append ( current . right ) NEW_LINE DEDENT if ( current . left ) : NEW_LINE INDENT parent [ current . left ] = current NEW_LINE nodeStack . append ( current . left ) NEW_LINE DEDENT