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.