protected function findInitialMigrationByCoreVersion($coreVersion, $criteria)
    {
        $coreVersionNormalized = preg_replace('/(\.0+)+$/', '', $coreVersion);
        if (version_compare($coreVersionNormalized, '5.7') < 0) {
            throw new Exception(t('Invalid version specified (%s).', $coreVersion));
        }
        $migrations = $this->getMigrations();
        $migrationIdentifiers = array_keys($migrations);
        $maxMigrationIndex = count($migrationIdentifiers) - 1;
        $result = null;
        foreach ($migrations as $identifier => $migration) {
            $migrationCoreVersionNormalized = preg_replace('/(\.0+)+$/', '', $migration->getMigration()->getDescription());
            if ($migrationCoreVersionNormalized !== '') {
                $cmp = version_compare($migrationCoreVersionNormalized, $coreVersionNormalized);
                if ($cmp <= 0 || $result === null) {
                    switch ($criteria) {
                        case static::FORCEDMIGRATION_INCLUSIVE:
                            $result = $migration;
                            break;
                        case static::FORCEDMIGRATION_EXCLUSIVE:
                            $migrationIndex = array_search($identifier, $migrationIdentifiers, false);
                            $result = $migrationIndex === $maxMigrationIndex ? null : $migrations[$migrationIdentifiers[$migrationIndex + 1]];
                            break;
                        default:
                            throw new Exception(t('Invalid initial migration criteria.'));
                    }
                }
                if ($cmp >= 0) {
                    break;
                }
            }
        }

        return $result;
    }