private static function mergeArraysRecursively($firstArray, $secondArray, $parentKeys)
    {
        $result = $firstArray;

        foreach ($secondArray as $key => $value) {
            if (array_key_exists($key, $firstArray)) {
                array_push($parentKeys, $key);
                $result[$key] = self::mergeTwoValues($firstArray[$key], $value, $parentKeys);
                array_pop($parentKeys);
            }
            else {
                $result[$key] = $value;
            }
        }

        return $result;
    }