docs: public static Path readCanonicalPath(Path path) throws IOException {
          if (!path.isAbsolute()) {
              path = path.toAbsolutePath();
          }
          if (path.toString().equals(File.separator)) {
              return path;
          }
  
          String fileName = path.getFileName().toString();
          if (".".equals(fileName)) {
              path = path.getParent();
              fileName = path.getFileName().toString();
          }
  
          // resolve ".." relative to the top of the path.
          int parents = 0;
          while ("..".equals(fileName)) {
              path = path.getParent();
              if (path == null || path.getFileName() == null) {
                  throw new IOException("Parent of root does not exist!");
              }
              fileName = path.getFileName().toString();
              ++parents;
          }
          while (parents-- > 0) {
              path = path.getParent();
              if (path == null || path.getFileName() == null) {
                  throw new IOException("Parent of root does not exist!");
              }
              fileName = path.getFileName().toString();
          }
  
          if (path.getParent() != null) {
              Path parent = readCanonicalPath(path.getParent());
              path = parent.resolve(fileName);
  
              if (Files.isSymbolicLink(path)) {
                  path = Files.readSymbolicLink(path);
                  if (!path.isAbsolute()) {
                      path = readCanonicalPath(parent.resolve(path));
                  }
              }
          }
  
          return path;
      }