Identify the index by identity rather than __eq__
Fix off-by-one

This was giving an index beyond the length of `before`.
Correctly insert at an existing parent if appropriate

At the end of a string (Case 2) the undo of a deletion of a placeable
(e.g. an XML tag) would be restored as plain text instead of part of
the existing tag.