deepestExecutableContext

fun <S> CommandContext<S>.deepestExecutableContext(): CommandContext<S>?

The context whose CommandContext.command should run for this parse.

A redirecting alias copies the target's command onto the alias node so a bare alias still executes. Brigadier then hangs that command on the outer context and puts any remaining parse (arguments, subcommands) on a child. CommandContext.getArgument does not look at children, so stopping at the first command != null would run the alias layer with empty arguments, or the parent handler instead of a subcommand.

The deepest context that actually has a command matches the consumed input. A bare alias has no child and lands on the copied command.