Merge overlapping patterns