private static Optional<SdFunctionDefinition> findFunction(String functionName, RankProfile profile) {
        Optional<SdFunctionDefinition> function = PsiTreeUtil.collectElementsOfType(profile.definition(), SdFunctionDefinition.class)
                                                             .stream()
                                                             .filter(f -> f.getName().equals(functionName))
                                                             .findAny();
        if (function.isPresent()) return function;
        for (var parent : profile.parents().values()) {
            function = findFunction(functionName, parent);
            if (function.isPresent()) return function;
        }
        return Optional.empty();
    }
Returns the first encountered function of the given name in the inheritance hierarchy
of the given profile, or empty if it is not present.

NOTE: Only profiles in the same file is considered
integration/intellij/src/main/java/ai/vespa/intellij/schema/SdUtil.java