Merge "Move duplicated union of HashSets logic into helper class"