protected function isLinkWrapped(DOMElement $element)
    {
        $parentNode = $element->parentNode;

        if ($parentNode instanceof DOMDocument) {
            return false;
        } elseif ($parentNode->localName === 'link') {
            $childCount = 0;

            /** @var \DOMText|\DOMElement $node */
            foreach ($parentNode->childNodes as $node) {
                if (!($node->nodeType === XML_TEXT_NODE && $node->isWhitespaceInElementContent())) {
                    ++$childCount;
                }
            }

            if ($childCount === 1) {
                return false;
            } else {
                return true;
            }
        }

        return $this->isLinkWrapped($parentNode);
    }