public function sameAs($other, $ignoreWhitespace, $ignoreCase)
    {
        if (is_string($other)) {
            $prev = libxml_use_internal_errors(true);
            $otherSimpleXml = @simplexml_load_string($other);
            libxml_use_internal_errors($prev);
            if (! ($otherSimpleXml instanceof SimpleXmlElement)) {
                throw new LogicException('Argument 0 was an invalid XML string');
            }
            $otherXml = new static($otherSimpleXml);
        } elseif ($other instanceof SimpleXmlElement) {
            $otherXml = new static($other);
        } elseif ($other instanceof self) {
            $otherXml = $other;
        } else {
            throw new LogicException(sprintf(
                'Argument 0 must be a string, a SimpleXmlElement or an instance of %s. %s given',
                __CLASS__,
                gettype($xml)
            ));
        }

        return $otherXml->struct($ignoreWhitespace, $ignoreCase) == $this->struct($ignoreWhitespace, $ignoreCase);
    }