private function doActions(
        array $actions,
        ModelIdInterface $after = null,
        ModelIdInterface $into = null,
        ModelIdInterface $parentModelId = null,
        array &$items = []
    ) {
        if ($parentModelId) {
            $parentModel = $this->modelCollector->getModel($parentModelId);
        } else {
            $parentModel = null;
        }

        // Holds models, that need deep-copy
        $deepCopyList = [];

        // Apply create and copy actions
        foreach ($actions as &$action) {
            $this->applyAction($action, $deepCopyList, $parentModel);
        }
        unset($action);

        // When pasting after another model, apply same grouping information
        $this->ensureSameGrouping($actions, $after);

        // Now apply sorting and persist all models
        $models = $this->sortAndPersistModels($actions, $after, $into, $parentModelId, $items);

        // At least, go ahead with the deep copy
        $this->doDeepCopy($deepCopyList);

        return $models;
    }