Take an XML document. Validate it.
Take all of the top level elements. Call getElementByID on each with the same value. Combine all the answers into an array, eliminating the nulls.
You might expect that array to have length one or zero on all valid documents. You’d be wrong, and dangerously so for some XML schemas. You can use the same ID on every node and I don’t know of a parser that would balk at that. And yet every implementation will return the first node that has that ID, which will then change any time you descend into the DOM.