The code, if I'm reading right, is not actually repeated:  One routine is for intersection, while the other is for union.  I'll move it into an implicit class anyway, just for fun.