public function getRecursiveFolders($folders)
    {
        if (! is_array($folders)) {
            $folders = [$folders];
        }

        $paths = [];

        foreach ($folders as $folder) {
            $iter = new Iterator(
                new DirectoryIterator($folder, DirectoryIterator::SKIP_DOTS),
                Iterator::SELF_FIRST,
                Iterator::CATCH_GET_CHILD // Ignore "Permission denied"
            );

            $subPaths = [$folder];
            foreach ($iter as $path => $dir) {
                if ($dir->isDir()) {
                    $subPaths[] = $path;
                }
            }

            $paths = array_merge($paths, $subPaths);
        }

        return $paths;
    }