public static function prepareFiles(array $files)
    {
        $return = [];

        foreach ($files as $key => $value) {
            if ($value instanceof UploadedFileInterface) {
                $return[$key] = $value;

                continue;
            }

            // Nested files
            if (is_array($value) && isset($value['tmp_name'])) {
                $return[$key] = static::createUploadedFile($value);

                continue;
            }

            // get next level files
            if (is_array($value)) {
                $return[$key] = static::prepareFiles($value);

                continue;
            }

            throw new \InvalidArgumentException('Invalid value in files specification');
        }

        return $return;
    }