private function sumUpWhitespace(HtmlDomParser $dom): HtmlDomParser
    {
        $text_nodes = $dom->find('//text()');
        foreach ($text_nodes as $text_node_wrapper) {
            /* @var $text_node \DOMNode */
            $text_node = $text_node_wrapper->getNode();
            $xp = $text_node->getNodePath();

            $doSkip = false;
            foreach (self::$skipTagsForRemoveWhitespace as $pattern) {
                if (\strpos($xp, "/${pattern}") !== false) {
                    $doSkip = true;

                    break;
                }
            }
            if ($doSkip) {
                continue;
            }

            $text_node->nodeValue = \preg_replace(self::$regExSpace, ' ', $text_node->nodeValue);
        }

        $dom->getDocument()->normalizeDocument();

        return $dom;
    }