private @Nullable Directory toDirectory(@Nullable File file) {
    return file == null || !file.isDirectory() ? null : (Directory) file;
  }
Returns the entry for the file in its parent directory. This will be the given entry unless the
name for the entry is "." or "..", in which the directory linking to the file is not the file's
parent directory. In that case, we know the file must be a directory ("." and ".." can only
link to directories), so we can just get the entry in the directory's parent directory that
links to it. So, for example, if we have a directory "foo" that contains a directory "bar" and
we find an entry [bar -> "." -> bar], we instead return the entry for bar in its parent, [foo
-> "bar" -> bar].
jimfs/src/main/java/com/google/common/jimfs/FileTree.java