public static function array_merge_recursive_distinct (array $array1, array $array2)
    {
        $result = $array1;

        foreach ($array2 as $key => $val) {
            if (is_array($array2[$key])) {
                $result[$key] = is_array($result[$key]) ? self::array_merge_recursive_distinct($result[$key], $array2[$key]) : $array2[$key];
            } else {
                $result[$key] = $val;
            }
        }

        return $result;
    }