public function preFlush(PreFlushEventArgs $args)
    {
        $scheduledInsertions = $args
            ->getEntityManager()
            ->getUnitOfWork()
            ->getScheduledEntityInsertions();

        foreach ($scheduledInsertions as $entity) {
            if ($entity instanceof CategoryInterface) {
                $this->removeParentCategoryForRootCategory($entity);
            }
        }

        return $this;
    }