code: function areNodesSimilar(left, right)
      {
          if (left === right)
              return true;
  
          if (left.nodeType() === Node.ELEMENT_NODE && right.nodeType() === Node.ELEMENT_NODE)
              return left.localName() === right.localName();
  
          if (left.nodeType() === right.nodeType())
              return true;
  
          // XPath treats CDATA as text nodes.
          var leftType = left.nodeType() === Node.CDATA_SECTION_NODE ? Node.TEXT_NODE : left.nodeType();
          var rightType = right.nodeType() === Node.CDATA_SECTION_NODE ? Node.TEXT_NODE : right.nodeType();
          return leftType === rightType;
      }
docs: Returns -1 in case of error, 0 if no siblings matching the same expression, <XPath index among the same expression-matching sibling nodes> otherwise.