public static List<SdDeclaration> findDeclarationsByName(PsiElement file, String name) {
        List<SdDeclaration> result = new ArrayList<>();
        
        for (SdDeclaration declaration : PsiTreeUtil.collectElementsOfType(file, SdDeclaration.class)) {
            if (name.equals(declaration.getName())) {
                result.add(declaration);
            }
        }
        return result;
    }
Util class for the plugin's code.

@author Shahar Ariel
@author bratseth
integration/intellij/src/main/java/ai/vespa/intellij/schema/SdUtil.java