Check for duplicate pixels IDs when adding to list. (rebased)

This is rebased from #2192, testing is pretty much that impacted integration tests pass.

--rebased-from #2192