public function deregisterEntity($entity)
    {
        $entityState = $this->getEntityState($entity);
        unset($this->aggregateRootChildren[$this->getObjectHashId($entity)]);

        if ($entityState == EntityStates::QUEUED || $entityState == EntityStates::REGISTERED) {
            $className                         = $this->getClassName($entity);
            $objectHashId                      = $this->getObjectHashId($entity);
            $entityId                          = $this->getEntityId($entity);
            $this->entityStates[$objectHashId] = EntityStates::UNREGISTERED;
            unset($this->entities[$className][$entityId]);
            $this->changeTracker->stopTracking($entity);
        }
    }