LPS-36411 Maintain all missing references even if the missing reference is the same entity

Hey Julio,

This is the fix for the missing references problem. Not it's being added multiple times.

I've added a new test case for the new changes as well to validate that there is no bug.

You can push it straight to Brian or you can cherry-pick to your branch it's up to you.

Thanks!

Máté