public static Collection<ExecutableResultWithDeDuping> generate(Iterator<SimilarityResult> iter, Map<FunctionDescription, Integer> duplicationInfo) {
		TreeSet<ExecutableResultWithDeDuping> res = new TreeSet<ExecutableResultWithDeDuping>();
		ExecutableResultWithDeDuping curres = new ExecutableResultWithDeDuping();
		while(iter.hasNext()) {
			SimilarityResult simres = iter.next();
			TreeSet<ExecutableResultWithDeDuping> exetree = new TreeSet<ExecutableResultWithDeDuping>();
			Iterator<SimilarityNote> noteiter = simres.iterator();
			
			Integer totalNumDuplicates = duplicationInfo.get(simres.getBase());  //should never be null
			if(totalNumDuplicates == null){
				totalNumDuplicates = 1000;
			}
			Map<ExecutableResultWithDeDuping, Integer> dupesInExecutable = new HashMap<ExecutableResultWithDeDuping, Integer>();
			
			while(noteiter.hasNext()) {
				SimilarityNote note = noteiter.next();
				curres.exerecord = note.getFunctionDescription().getExecutableRecord();
				curres.id = curres.exerecord.getRowId();
				ExecutableResultWithDeDuping tmpres = exetree.floor(curres);
				if ((tmpres == null)||(!tmpres.id.equals(curres.id))) {			// Haven't seen this executable before
					tmpres = new ExecutableResultWithDeDuping(curres.exerecord);
					exetree.add(tmpres);
					tmpres.sumsignif = note.getSignificance();
					dupesInExecutable.put(tmpres, 1);
				}
				else {	// Seen this executable before for this SimilarityResult

					if (tmpres.sumsignif < note.getSignificance()){
						tmpres.sumsignif = note.getSignificance();		// Find maximum significance result for this executable
						dupesInExecutable.put(tmpres, 1);               //found a higher significance match - reset the count
					}
					else{
						if( (tmpres.sumsignif == note.getSignificance())  && (dupesInExecutable.get(tmpres) < totalNumDuplicates)){
							tmpres.sumsignif = tmpres.sumsignif + note.getSignificance();
							dupesInExecutable.put(tmpres, dupesInExecutable.get(tmpres) + 1);     //increment the count
						}

					}
				}
			}

			Iterator<ExecutableResultWithDeDuping> finaliter = exetree.iterator();
			while(finaliter.hasNext()) {
				ExecutableResultWithDeDuping eres = finaliter.next();
				ExecutableResultWithDeDuping tmpres = res.floor(eres);
				if ((tmpres == null)||(!tmpres.id.equals(eres.id))) {
					tmpres = new ExecutableResultWithDeDuping(eres.exerecord);
					res.add(tmpres);
				}
				tmpres.addFunction(eres.sumsignif);
			}
		}
		return res;
	}
@return sum of significance scores for all matching functions
Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/protocol/ExecutableResultWithDeDuping.java