private function ensureSameGrouping(array $actions, ModelIdInterface $after = null)
    {
        $environment  = $this->getEnvironment();
        $groupingMode = ViewHelpers::getGroupingMode($environment);
        if ($groupingMode && $after && $after->getId()) {
            // when pasting after another item, inherit the grouping field
            $groupingField = $groupingMode['property'];
            $previous      = $this->modelCollector->getModel($after);
            $groupingValue = $previous->getProperty($groupingField);

            foreach ($actions as $action) {
                /** @var ModelInterface $model */
                $model = $action['model'];
                $model->setProperty($groupingField, $groupingValue);
            }
        }
    }