Tidy up compareDocumentPosition code. Remove old implemetation. Add ENTITY_REFERENCE_NODE to obsolete node types