public static function removeEmptyDirsToPath($dir, $path)
    {
        $dir = rtrim($dir, DIRECTORY_SEPARATOR);
        $path = rtrim($path, DIRECTORY_SEPARATOR);

        while ($dir != $path) {
            if (!static::removeDirIfEmpty($dir)) {
                break;
            }

            $dir = pathinfo($dir, PATHINFO_DIRNAME);
        }
    }