Back to the incorrect referencing business, <guessing> it may be because when entities are deleted they aren't truly deleted per se, that is, they are flagged for deletion but still reside in the drawing database. When the drawing is saved entities flagged for deletion don't get to go along for the ride, thus are deleted. The fact that they still reside in the database seems to trip up the ability to tell whether there are fully disassociated from other entities.
Regarding the authorship of my initial code snip I based it on about a minute of observation in my hotlinked props utility - I can dynamically hop from entity to entity, object to object, as long as the target object / entity name is valid (not deleted) by merely double clicking the object / ename. Observe --
While I've little doubt Tony probably penned something similar years ago (generally speaking he's light years ahead of the great unwashed) he was not the source of what I had posted.