Fix #858: Selection: Avoid range confusion involving orphaned nodes

If an update occurs on the row at which a selection range was started, and the user later shift+selects, an infinite loop occurs because Selection wrongly assumes that the element from the starting row is still in the document, when it was actually replaced with a new one.  This works around that by detecting if the element is no longer in the document, and grabbing the equivalent element that is in the document instead.