Removes redundant contains in a filter.