Collapses records sharing an ExternalID within one batch, keeping the LAST occurrence in its
original position. Returns the input array unchanged (same reference) when every identity is
already unique, so the ordinary path allocates nothing.
A record with an empty or missing ExternalID is passed through untouched: identity-less records
are a separate defect with a separate guard, and silently collapsing them here would merge
unrelated rows.
Collapses records sharing an ExternalID within one batch, keeping the LAST occurrence in its original position. Returns the input array unchanged (same reference) when every identity is already unique, so the ordinary path allocates nothing.
A record with an empty or missing ExternalID is passed through untouched: identity-less records are a separate defect with a separate guard, and silently collapsing them here would merge unrelated rows.