Merge equal states