code: public static Path deepestNonGlobPath(Path input) {
      Path commonRoot = input;
  
      while (commonRoot != null && isGlob(commonRoot)) {
        commonRoot = commonRoot.getParent();
      }
      return commonRoot;
    }
docs: Finds the deepest ancestor of input that is not a glob.