#NEWLINE# def optimize( self , info , in_set = False ) : #NEWLINE# #INDENT# items = [ ] #NEWLINE# for item in self . items : #NEWLINE# #INDENT# item = item . optimize ( info , in_set = True ) #NEWLINE# if ( isinstance ( item , SetUnion ) and item . positive ) : #NEWLINE# #INDENT# items . extend ( item . items ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# items . append ( info ) #NEWLINE# #UNINDENT# #UNINDENT# if ( ( len ( items ) == 1 ) and ( not isinstance ( items [ 0 ] , Range ) ) ) : #NEWLINE# #INDENT# return items [ 0 ] . with_flags ( positive = ( items [ 0 ] . positive == self . positive ) , case_insensitive = self . case_insensitive , zerowidth = self . zerowidth ) . optimize ( info , in_set = in_set ) #NEWLINE# #UNINDENT# return SetUnion ( self . info , items , positive = self . positive , case_insensitive = self . case_insensitive , zerowidth = self . zerowidth )