Merge partially duplicate patterns