private function deleteCacheSubfoldersIfEmpty($filepath)
    {
        if ($this->cache_path == $filepath) {
            // Do not delete main cache folder itself.
            return true;
        }

        $filepath_exp = explode(DIRECTORY_SEPARATOR, $filepath);
        if (is_array($filepath_exp)) {
            for ($i = count($filepath_exp)-1; $i >= 0 ; $i--) {
                $dir = implode(DIRECTORY_SEPARATOR, $filepath_exp);
                $iterator = new \FilesystemIterator($dir);
                $isDirEmpty = !$iterator->valid();
                unset($iterator);

                if ($this->cache_path == $dir) {
                    // Do not delete main cache folder.
                    return true;
                } elseif (is_dir($dir) && !is_writable($dir)) {
                    // Directory is unable to delete.
                    return false;
                } elseif (is_dir($dir) && $isDirEmpty !== true) {
                    // Directory is not empty.
                    return true;
                } elseif (is_dir($dir) && $isDirEmpty === true && is_writable($dir) && $this->cache_path != $dir) {
                    rmdir($dir);
                    unset($filepath_exp[$i]);
                } else {
                    return true;
                }
            }
            unset($i);
        }
        unset($filepath_exp);

        return true;
    }