public function makeNestedAndUniquePath($filename, $disk = null) {

        // If no disk defined, get it from the current mount mananger
        if (empty($disk)) $disk = $this->manager->getFilesystem('disk');

        // Remove unsafe characters from the filename
        // https://regex101.com/r/mJ3sI5/1
        $filename = preg_replace('#[^\w-_\.]#i', '_', $filename);

        // Create nested folders to store the file in
        $dir = '';
        for ($i=0; $i<$this->depth; $i++) {
            $dir .= str_pad(mt_rand(0, $this->length - 1), strlen($this->length), '0', STR_PAD_LEFT).'/';
        }

        // If this file doesn't already exist, return it
        $path = $dir.$filename;
        if (!$disk->has($path)) return $path;

        // Get a unique filename for the file and return it
        $file = pathinfo($filename, PATHINFO_FILENAME);
        $i = 1;
        $ext = pathinfo($filename, PATHINFO_EXTENSION);
        while ($disk->has($path = $dir.$file.'-'.$i.'.'.$ext)) { $i++; }
        return $path;

    }