private function sortAndPersistModels(
        array $actions,
        ModelIdInterface $after = null,
        ModelIdInterface $into = null,
        ModelIdInterface $parentModelId = null,
        array &$items = []
    ) {
        /** @var DefaultCollection|ModelInterface[] $models */
        $models = $this->createModelCollectionFromActions($actions, $items);

        $this->triggerPrePasteModel($models);

        $this->processPasteAfter($models, $after);
        $this->processPasteInto($models, $into);
        $this->processPasteTopWithoutReference($models, $after, $into, $parentModelId);
        $this->processPasteTopAfterModel($models, $parentModelId);

        if ($models->count()) {
            throw new DcGeneralRuntimeException('Invalid parameters.');
        }

        return $models;
    }