question: private static SelectResults sizeSortedUnion ( SelectResults small , SelectResults large , ExecutionContext contextOrNull ) { boolean smallModifiable = small . isModifiable ( ) && ( isBag ( small ) || ! isBag ( large ) ) ; boolean largeModifiable = large . isModifiable ( ) && ( isBag ( large ) || ! isBag ( small ) ) ; if ( largeModifiable ) { try { for ( Iterator itr = small . iterator ( ) ; itr . hasNext ( ) ; ) { Object element = itr . next ( ) ; int count = small . occurrences ( element ) ; if ( large . occurrences ( element ) < count ) { large . add ( element ) ; } } return large ; } catch ( UnsupportedOperationException e1 ) { } } if ( smallModifiable ) { try { for ( Iterator itr = large . iterator ( ) ; itr . hasNext ( ) ; ) { Object element = itr . next ( ) ; int count = large . occurrences ( element ) ; if ( small . occurrences ( element ) < count ) { small . add ( element ) ; } } return small ; } catch ( UnsupportedOperationException e2 ) { } } SelectResults rs ; if ( contextOrNull != null ) { rs = contextOrNull . isDistinct ( ) ? new ResultsSet ( large ) : new ResultsBag ( large , contextOrNull . getCachePerfStats ( ) ) ; } else { rs = new ResultsBag ( large , null ) ; } for ( Iterator itr = small . iterator ( ) ; itr . hasNext ( ) ; ) { Object element = itr . next ( ) ; rs . add ( element ) ; } return rs ; }
target:  collections are passed in from smallest to largest 