public function setRemoved($removed): void
    {
        if (!$this->isNodeDataMatchingContext()) {
            $this->materializeNodeData();
        }

        if ((boolean)$removed === true) {
            /** @var $childNode Node */
            foreach ($this->getChildNodes() as $childNode) {
                $childNode->setRemoved(true);
            }

            $this->nodeData->setRemoved(true);
            $this->emitNodeRemoved($this);
        } else {
            $this->nodeData->setRemoved(false);
            $this->emitNodeUpdated($this);
        }

        $this->context->getFirstLevelNodeCache()->flush();
    }