Avoid seeing end of self-closing tag as filepath
Only call real_index() if necessary

If normalisation leaves the string unchanged, just use the indexes
as-is, instead of using the expensive real_index() method to calculate
them.
Fixes comment to match the real purpose of the file
Optionally accept a parameter with the preferred parent

This helps us to reconstruct a tree closer to what it was when we undo
from a delete, for example. This fixes some errors when we undo a delete
that happened at the boundary between a placeable (for example ph) and
the text next to it.
Fix a syntax error in Python 3

`[filename for filename in 'COPYING', 'README.rst']` is only valid in Python 2.