public static function recursiveDiff($array1, $array2, $caseInsensitive = true, $matchingKeysOnly = true) {

        if ($array1 instanceof AssociativeArray) {
            $array1 = $array1->toArray();
        }

        if ($array2 instanceof AssociativeArray) {
            $array2 = $array2->toArray();
        }

        $sharedKeys = array_intersect(array_keys($array1), array_keys($array2));

        $diffArray = array();

        // Only care about shared keys
        foreach ($sharedKeys as $key) {
            if ((is_array($array1[$key]) || $array1[$key] instanceof AssociativeArray) && (is_array($array2[$key]) || $array2[$key] instanceof AssociativeArray)) {

                $diffArray[$key] = ArrayUtils::recursiveDiff($array1[$key], $array2[$key], $caseInsensitive, $matchingKeysOnly);

            } else {

                $value1 = $caseInsensitive ? strtolower($array1[$key]) : $array1[$key];
                $value2 = $caseInsensitive ? strtolower($array2[$key]) : $array2[$key];

                if ($value1 != $value2) {
                    $diffArray[$key] = array("value1" => $array1[$key], "value2" => $array2[$key]);
                }
            }
        }

        return $diffArray;

    }