unlinkDirectory = (tree, dir) => {
  const { pathname } = dir
  const subDirectories = getSubdirectoriesFromRoot(tree.pathname, pathname)

  subDirectories.pop()
  let currentFolder = tree.folders
  for (const directoryName of subDirectories) {
    const childFolder = currentFolder.find(f => f.name === directoryName)
    if (!childFolder) return
    currentFolder = childFolder.folders
  }

  const index = currentFolder.findIndex(f => f.pathname === pathname)
  if (index !== -1) {
    currentFolder.splice(index, 1)
  }
}
Remove the given directory from the tree list.

@param {*} tree Root file tree
@param {*} dir The directory that should be deleted