public function compileBlocks()
    {
        do {
            $blockProceeded = 0;
            foreach ($this->getBlocks() as $name => $blocks) {
                foreach ($blocks as $block) {
                    $this->assert(
                        $block instanceof BlockElement,
                        'Unexpected block for the name '.$name,
                        $block instanceof AbstractElement ? $block->getOriginNode() : null
                    );
                    /** @var BlockElement $block */
                    if ($block->hasParent()) {
                        $this->replaceBlock($block);
                        $blockProceeded++;
                    }
                }
            }
        } while ($blockProceeded);

        return $this;
    }