public function _mergeWithPrevious($previous)
    {
        if ($previous == null)
        {
            return $this;
        }
        if ($previous instanceof AVRelationOperation)
        {
            if ($previous->targetClassName != null && $previous->targetClassName != $this->targetClassName
            )
            {
                throw new \Exception('Related object object must be of class ' . $this->targetClassName . ', but ' . $previous->targetClassName . ' was passed in.');
            }
            $newRelationToAdd = self::convertToOneDimensionalArray($this->relationsToAdd);
            $newRelationToRemove = self::convertToOneDimensionalArray($this->relationsToRemove);

            $previous->addObjects($newRelationToAdd, $previous->relationsToAdd);
            $previous->removeObjects($newRelationToAdd, $previous->relationsToRemove);

            $previous->removeObjects($newRelationToRemove, $previous->relationsToAdd);
            $previous->addObjects($newRelationToRemove, $previous->relationsToRemove);

            $newRelationToAdd = self::convertToOneDimensionalArray($previous->relationsToAdd);
            $newRelationToRemove = self::convertToOneDimensionalArray($previous->relationsToRemove);

            return new AVRelationOperation($newRelationToAdd, $newRelationToRemove);
        }
        throw new \Exception('Operation is invalid after previous operation.');
    }