Most of #1794 done, except for nodes not in the same tree

Add compareDocumentPosition (fixes #1794) to Node