code: func removeEmptyDirs(baseDir, endDir string) error {
  	if !mount.PathWithinBase(endDir, baseDir) {
  		return fmt.Errorf("endDir %q is not within baseDir %q", endDir, baseDir)
  	}
  
  	for curDir := endDir; curDir != baseDir; curDir = filepath.Dir(curDir) {
  		s, err := os.Stat(curDir)
  		if err != nil {
  			if os.IsNotExist(err) {
  				klog.V(5).Infof("curDir %q doesn't exist, skipping", curDir)
  				continue
  			}
  			return fmt.Errorf("error stat %q: %v", curDir, err)
  		}
  		if !s.IsDir() {
  			return fmt.Errorf("path %q not a directory", curDir)
  		}
  
  		err = os.Remove(curDir)
  		if os.IsExist(err) {
  			klog.V(5).Infof("Directory %q not empty, not removing", curDir)
  			break
  		} else if err != nil {
  			return fmt.Errorf("error removing directory %q: %v", curDir, err)
  		}
  		klog.V(5).Infof("Removed directory %q", curDir)
  	}
  	return nil
  }
docs: // removeEmptyDirs works backwards from endDir to baseDir and removes each directory
  // if it is empty.  It stops once it encounters a directory that has content