Remove duplicate pattern and add predicate checks on other patterns.