public function removeNodesWithInvalidWorkspace()
    {
        $this->dispatch(self::EVENT_NOTICE, 'Checking for nodes with invalid workspace ...');

        $nodesArray = $this->collectNodesWithInvalidWorkspace();
        if ($nodesArray === []) {
            return;
        }
        $numberOfNodes = count($nodesArray);
        $taskDescription = sprintf('Remove <i>%d</i> node%s referring to an invalid workspace.', $numberOfNodes, $numberOfNodes > 1 ? 's' : '');
        $taskClosure = function () use ($nodesArray) {
            foreach ($nodesArray as $nodeArray) {
                $this->removeNode($nodeArray['identifier'], $nodeArray['dimensionsHash']);
            }
        };
        $taskRequiresConfirmation = true;
        $this->dispatch(self::EVENT_TASK, $taskDescription, $taskClosure, $taskRequiresConfirmation);
    }