protected function removeElement($element, $contents)
    {
        $newContents = preg_replace('@'.$element->regex.'@xi', '', $contents);

        if ($newContents !== $contents && isset($element->elements)) {
            foreach ($element->elements as $element) {
                $newContents = $this->removeElement($element, $newContents);
            }
        }

        return $newContents;
    }