protected function saveNodesAndTearDownRootNodeAndRepository()
{
if ($this->nodeDataRepository !== null) {
$this->nodeDataRepository->flushNodeRegistry();
}
/** @var NodeFactory $nodeFactory */
$nodeFactory = $this->objectManager->get(NodeFactory::class);
$nodeFactory->reset();
$this->contextFactory->reset();
$this->persistenceManager->persistAll();
$this->persistenceManager->clearState();
$this->nodeDataRepository = null;
$this->rootNode = null;
}