private static void removeSymbolFromIndex(ParseContext context, SchemaNode node) {
        // walk down first-child path and remove the first symbol found 
        // because some branches of the tree look like a long chain
        while (true) {
            if (node.hasSymbol()) {
                Symbol symbol = node.getSymbol();
                if (symbol.getStatus() == SymbolStatus.REFERENCE) {
                    context.schemaIndex().deleteSymbolReference(symbol);
                }
                node.removeSymbol();
                return;
            }
            if (node.size() > 0)node = node.get(0).getSchemaNode();
            else break;
        }
    }
Resolves rank expression references in the tree

@param node        The schema node to resolve the rank expression references in.
@param context     The parse context.
integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/schemadocument/resolvers/RankExpressionSymbolResolver.java