diff --git a/core/lib/Drupal/Component/Utility/NestedArray.php b/core/lib/Drupal/Component/Utility/NestedArray.php
index acfdc2f..1e97bf6 100644
--- a/core/lib/Drupal/Component/Utility/NestedArray.php
+++ b/core/lib/Drupal/Component/Utility/NestedArray.php
@@ -342,4 +342,41 @@ public static function mergeDeepArray(array $arrays, $preserve_integer_keys = FA
     return $result;
   }
 
+  /**
+   * Recursively computes the difference of arrays with additional index check.
+   *
+   * This is a version of array_diff_assoc() that supports multidimensional
+   * arrays.
+   *
+   * @param array $array1
+   *   The array to compare from.
+   * @param array $array2
+   *   The array to compare to.
+   *
+   * @return array
+   *   Returns an array containing all the values from array1 that are not present
+   *   in array2.
+   */
+  public static function diffAssocRecursiveArray(array $array1, array $array2) {
+    $difference = array();
+    foreach ($array1 as $key => $value) {
+      if (is_array($value)) {
+        if (!isset($array2[$key]) || !is_array($array2[$key])) {
+          $difference[$key] = $value;
+        }
+        else {
+          $new_diff = static::diffAssocRecursiveArray($value, $array2[$key]);
+          if (!empty($new_diff)) {
+            $difference[$key] = $new_diff;
+          }
+        }
+      }
+      elseif (!array_key_exists($key, $array2) || $array2[$key] !== $value) {
+        $difference[$key] = $value;
+      }
+    }
+
+    return $difference;
+  }
+
 }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/ArrayUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/NestedArrayUnitTest.php
similarity index 86%
rename from core/modules/system/lib/Drupal/system/Tests/Common/ArrayUnitTest.php
rename to core/modules/system/lib/Drupal/system/Tests/Common/NestedArrayUnitTest.php
index 144e448..566740a 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/ArrayUnitTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/NestedArrayUnitTest.php
@@ -2,7 +2,7 @@
 
 /**
  * @file
- * Definition of Drupal\system\Tests\Common\ArrayUnitTest.
+ * Contains \Drupal\system\Tests\Common\NestedArrayUnitTest.
  */
 
 namespace Drupal\system\Tests\Common;
@@ -143,4 +143,30 @@ function testMergeDeepArray() {
     );
     $this->assertIdentical(NestedArray::mergeDeepArray(array($link_options_1, $link_options_2)), $expected, 'NestedArray::mergeDeepArray() returned a properly merged array.');
   }
+
+  /**
+   * Tests NestedArray::diffAssocRecursiveArray().
+   */
+  public function testDiffAssocRecursiveArray() {
+    $array_1 = array(
+      'same' => 'same',
+      'array_empty_diff' => array(),
+      'null' => NULL,
+      'int_diff' => 1,
+      'array_diff' => array('same' => 'same'),
+    );
+    $array_2 = array(
+      'same' => 'same',
+      'array_empty_diff' => array(),
+      'null' => NULL,
+      'int_diff' => '1',
+      'array_diff' => array('same' => 'different'),
+    );
+    $expected = array(
+      'int_diff' => 1,
+      'array_diff' => array('same' => 'same'),
+    );
+
+    $this->assertIdentical(NestedArray::diffAssocRecursiveArray($array_1, $array_2), $expected);
+  }
 }
