private function doDetach($xmlEntity, array &$visited)
    {
        $oid = spl_object_hash($xmlEntity);
        if (isset($visited[$oid])) {
            return; // Prevent infinite recursion
        }

        $visited[$oid] = $xmlEntity; // mark visited

        switch ($this->getXmlEntityState($xmlEntity, self::STATE_DETACHED)) {
            case self::STATE_MANAGED:
                $this->removeFromIdentityMap($xmlEntity);
                unset($this->entityIdentifiers[$oid], $this->entityUpdates[$oid],
                        $this->entityDeletions[$oid], $this->entityIdentifiers[$oid],
                        $this->entityStates[$oid], $this->originalEntityData[$oid]);
                break;
            case self::STATE_NEW:
            case self::STATE_DETACHED:
                return;
        }

        //$this->cascadeDetach($document, $visited);
    }