protected function setPath(string $path, bool $checkForExistence = true): void
    {
        $originalPath = $this->nodeData->getPath();
        if ($originalPath === $path) {
            return;
        }

        $pathAvailable = $checkForExistence ? $this->isNodePathAvailable($path) : true;
        if (!$pathAvailable) {
            throw new NodeException(sprintf('Can not rename the node "%s" as a node already exists on path "%s"', $this->getPath(), $path), 1414436551);
        }

        $changedNodePathsCollection = $this->setPathInternal($path, !$checkForExistence);
        $this->nodeDataRepository->persistEntities();
        array_walk($changedNodePathsCollection, function ($changedNodePathInformation) {
            call_user_func_array([
                $this,
                'emitNodePathChanged'
            ], $changedNodePathInformation);
        });
    }