diff --git a/core/modules/migrate/src/Plugin/Migration.php b/core/modules/migrate/src/Plugin/Migration.php
index 9b22e35..855859d 100644
--- a/core/modules/migrate/src/Plugin/Migration.php
+++ b/core/modules/migrate/src/Plugin/Migration.php
@@ -662,7 +662,30 @@ public function setTrackLastImported($track_last_imported) {
    * {@inheritdoc}
    */
   public function getMigrationDependencies() {
-    return $this->migration_dependencies + ['required' => [], 'optional' => []];
+    $this->migration_dependencies += ['required' => [], 'optional' => []];
+    $this->migration_dependencies['optional'] = array_unique(array_merge($this->migration_dependencies['optional'], $this->findMigrationDependencies($this->getProcess())));
+    return $this->migration_dependencies;
+  }
+
+  /**
+   * Find migration dependencies from the migration and the iterator plugins.
+   *
+   * @param $process
+   * @return array
+   */
+  protected function findMigrationDependencies($process) {
+    $return = [];
+    foreach ($process as $process_pipeline) {
+      foreach ($process_pipeline as $plugin_configuration) {
+        if ($plugin_configuration['plugin'] == 'migration') {
+          $return = array_merge($return, (array) $plugin_configuration['migration']);
+        }
+        if ($plugin_configuration['plugin'] == 'iterator') {
+          $return = array_merge($return, $this->findMigrationDependencies($this->getProcessNormalized($plugin_configuration['process'])));
+        }
+      }
+    }
+    return $return;
   }
 
   /**
diff --git a/core/modules/migrate/tests/src/Unit/MigrateDependenciesTest.php b/core/modules/migrate/tests/src/Unit/MigrateDependenciesTest.php
new file mode 100644
index 0000000..c7fd0a3
--- /dev/null
+++ b/core/modules/migrate/tests/src/Unit/MigrateDependenciesTest.php
@@ -0,0 +1,47 @@
+<?php
+
+namespace Drupal\Tests\migrate\Unit;
+
+use Drupal\migrate\Plugin\MigrateDestinationPluginManager;
+use Drupal\migrate\Plugin\MigratePluginManager;
+use Drupal\migrate\Plugin\Migration;
+use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
+use Drupal\Tests\UnitTestCase;
+
+/**
+ * Tests the findMigrationDependencies() method.
+ *
+ * @group migrate
+ */
+class MigrateDependenciesTest extends UnitTestCase {
+
+  public function testFindMigrationDependencies() {
+    $plugin_definition = [
+      'process' => [
+        'f1' => 'bar',
+        'f2' => [
+          'plugin' => 'migration',
+          'migration' => 'm1'
+        ],
+        'f3' => [
+          'plugin' => 'iterator',
+          'process' => [
+            'target_id' => [
+              'plugin' => 'migration',
+              'migration' => 'm2',
+            ],
+          ],
+        ],
+      ],
+    ];
+    $migrate_plugin_manager = $this->prophesize(MigratePluginManager::class)->reveal();
+    $migration = new Migration([], '', $plugin_definition,
+      $this->prophesize(MigrationPluginManagerInterface::class)->reveal(),
+      $migrate_plugin_manager,
+      $migrate_plugin_manager,
+      $this->prophesize(MigrateDestinationPluginManager::class)->reveal(),
+      $migrate_plugin_manager
+    );
+    $this->assertSame(['required' => [], 'optional' => ['m1', 'm2']], $migration->getMigrationDependencies());
+  }
+}
