private InternalSelector parseSelectorFunction() {
        int functionPosition = position();
        String name = ParserUtils.parseIdentifier(this);
        List<InternalSelector> selectors = parseSelectorFunctionArgs();
        switch (name) {
            case "not":
                if (selectors.size() != 1) {
                    throw new SelectorSyntaxException(
                            "The :not function requires a single selector argument",
                            input().toString(),
                            functionPosition,
                            line(),
                            column());
                }
                return new NotSelector(selectors.get(0));
            case "test":
                return new TestSelector(selectors);
            case "is":
                return IsSelector.of(selectors);
            case "in":
                if (selectors.size() != 1) {
                    throw new SelectorSyntaxException(
                            "The :in function requires a single selector argument",
                            input().toString(),
                            functionPosition,
                            line(),
                            column());
                }
                return new InSelector(selectors.get(0));
            case "root":
                if (selectors.size() != 1) {
                    throw new SelectorSyntaxException(
                            "The :root function requires a single selector argument",
                            input().toString(),
                            functionPosition,
                            line(),
                            column());
                }
                InternalSelector root = new RootSelector(selectors.get(0), roots.size());
                roots.add(selectors.get(0));
                return root;
            case "topdown":
                if (selectors.size() > 2) {
                    throw new SelectorSyntaxException(
                            "The :topdown function accepts 1 or 2 selectors, but found " + selectors.size(),
                            input().toString(),
                            functionPosition,
                            line(),
                            column());
                }
                return new TopDownSelector(selectors);
            case "recursive":
                if (selectors.size() != 1) {
                    throw new SelectorSyntaxException(
                            "The :recursive function requires a single selector argument",
                            input().toString(),
                            functionPosition,
                            line(),
                            column());
                }
                return new RecursiveSelector(selectors.get(0));
            case "each":
                LOGGER.warning("The `:each` selector function has been renamed to `:is`: " + input());
                return IsSelector.of(selectors);
            default:
                LOGGER.warning(String.format("Unknown function name `%s` found in selector: %s",
                        name,
                        input()));
                return (context, shape, next) -> InternalSelector.Response.CONTINUE;
        }
    }
Filter out unnecessary identity selectors when creating the finalized AST to evaluate selectors.
smithy-model/src/main/java/software/amazon/smithy/model/selector/SelectorParser.java