Map<ByteString, RegionSpecificSeqId> id2Map = MessageIdUtils.inMapForm(id2);
for (RegionSpecificSeqId rrsid1 : id1.getRemoteComponentsList()) {
ByteString region = rrsid1.getRegion();
RegionSpecificSeqId rssid2 = id2Map.get(region);
if (rssid2 == null) {
newIdBuilder.addRemoteComponents(rrsid1);
continue;
}
newIdBuilder.addRemoteComponents((rrsid1.getSeqId() > rssid2.getSeqId()) ? rrsid1 : rssid2);
// remove from map
id2Map.remove(region);
}