The compareDocumentPosition() method of the Node interface reports the position of its argument node relative to the node on which it is called.
compareDocumentPosition()
external int compareDocumentPosition(Node other);