public static function setKeysAsValues(array $array, $ignoreDuplicatedValues = true)
    {
        /*
         * No elements?
         * Nothing to do
         */
        if (empty($array)) {
            return null;
        }

        $replaced = [];

        foreach ($array as $key => $value) {
            /*
             * The value it's an array?
             * Let's replace keys with values in this array first
             */
            if (is_array($value)) {
                $replaced[$key] = self::setKeysAsValues($value, $ignoreDuplicatedValues);

                continue;
            }

            // Duplicated values shouldn't be ignored and processed value is used as key already?
            // Let's use an array and that will contain all values (to avoid ignoring / overriding duplicated values)
            if (!$ignoreDuplicatedValues && isset($replaced[$value])) {
                $existing = self::makeArray($replaced[$value]);

                $replaced[$value] = array_merge($existing, [
                    $key,
                ]);

                continue;
            }

            // Standard behaviour
            $replaced[$value] = $key;
        }

        return $replaced;
    }