public static Optional<URI> findSchemaDirectory(URI initialURI) {
        Path path = Paths.get(initialURI);
        while (path != null && path.getFileName() != null) {
            if (path.getFileName().toString().equals("schemas")) {
                break;
            }
            path = path.getParent();
        }

        if (path == null || path.getFileName() == null) {
            return Optional.empty();
        }
        return Optional.of(path.toUri());
    }
Searches among the parents for a directory named "schemas"
integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/common/FileUtils.java