public function groupVersions($results)
    {
        $property = $this->versionAssociation()->getProperty();

        return $results->map(function (EntityInterface $row) use ($property) {
            $versionField = $this->_config['versionField'];
            $versions = (array)$row->get($property);
            $grouped = new Collection($versions);

            $result = [];
            foreach ($grouped->combine('field', 'content', 'version_id') as $versionId => $keys) {
                $entityClass = $this->_table->getEntityClass();
                $versionData = [
                    $versionField => $versionId
                ];

                $keys = $this->_convertFieldsToType($keys, 'toPHP');

                /* @var \Cake\Datasource\EntityInterface $versionRow */
                $versionRow = $grouped->match(['version_id' => $versionId])->first();

                foreach ($this->_config['additionalVersionFields'] as $mappedField => $field) {
                    if (!is_string($mappedField)) {
                        $mappedField = 'version_' . $field;
                    }
                    $versionData[$mappedField] = $versionRow->get($field);
                }

                $version = new $entityClass($keys + $versionData, [
                    'markNew' => false,
                    'useSetters' => false,
                    'markClean' => true
                ]);
                $result[$versionId] = $version;
            }

            $options = ['setter' => false, 'guard' => false];
            $row->set('_versions', $result, $options);
            unset($row[$property]);
            $row->clean();

            return $row;
        });
    }