private @Nullable CompletableFuture<@Nullable Command<C>> attemptParseUnambiguousChild(
            final @NonNull List<@NonNull CommandComponent<C>> parsedArguments,
            final @NonNull CommandContext<C> commandContext,
            final @NonNull CommandNode<C> root,
            final @NonNull CommandInput commandInput,
            final @NonNull Executor executor
    ) {
        final C sender = commandContext.sender();
        final List<CommandNode<C>> children = root.children();

        // Check whether it matches any of the static arguments If so, do not attempt parsing as a dynamic argument
        if (!commandInput.isEmpty() && this.matchesLiteral(children, commandInput.peekString())) {
            return null;
        }

        // If it does not match a literal, try to find the one argument node, if it exists
        // The ambiguity check guarantees that only one will be present
        final List<CommandNode<C>> argumentNodes = children.stream()
                .filter(n -> (n.component() != null && n.component().type() != CommandComponent.ComponentType.LITERAL))
                .collect(Collectors.toList());
        if (argumentNodes.size() > 1) {
            throw new IllegalStateException("Unexpected ambiguity detected, number of dynamic child nodes should not exceed 1");
        } else if (argumentNodes.isEmpty()) {
            return null;
        }
        final CommandNode<C> child = argumentNodes.get(0);

        // Check if we're allowed to execute the child command. If not, exit
        final Optional<PermissionResult> childCheck = this.determineAccess(sender, child);
        if (!childCheck.isPresent()) {
            return CompletableFutures.failedFuture(
                    new InvalidCommandSenderException(
                            sender,
                            child.nodeMeta().get(CommandNode.META_KEY_SENDER_TYPES),
                            this.getComponentChain(child),
                            null
                    )
            );
        }
        if (!commandInput.isEmpty() && childCheck.get().denied()) {
            return CompletableFutures.failedFuture(
                    new NoPermissionException(
                            childCheck.get(),
                            sender,
                            this.getComponentChain(child)
                    )
            );
        }

        // If the child has no argument it cannot be executed, so we exit
        if (child.component() == null) {
            return null;
        }

        // This stores the argument value for this argument.
        ArgumentParseResult<?> argumentValue = null;

        // Flag arguments need to be skipped over, so that further defaults are handled
        if (commandInput.isEmpty() && !(child.component().type() == CommandComponent.ComponentType.FLAG)) {
            final CommandComponent<C> childComponent = Objects.requireNonNull(child.component());
            if (childComponent.hasDefaultValue()) {
                final DefaultValue<C, ?> defaultValue = Objects.requireNonNull(childComponent.defaultValue(), "defaultValue");

                if (defaultValue instanceof DefaultValue.ParsedDefaultValue) {
                    return this.attemptParseUnambiguousChild(
                            parsedArguments,
                            commandContext,
                            root,
                            commandInput.appendString(((DefaultValue.ParsedDefaultValue<C, ?>) defaultValue).value()),
                            executor
                    );
                } else {
                    argumentValue = defaultValue.evaluateDefault(commandContext);
                }
            } else if (!child.component().required()) {
                if (child.command() == null) {
                    // If there are multiple children with different owning commands then it's ambiguous and
                    // not allowed, therefore we're able to pick any child command, as long as we can find it
                    CommandNode<C> node = child;
                    while (!node.isLeaf()) {
                        node = node.children().get(0);
                        final CommandComponent<C> nodeComponent = node.component();
                        if (nodeComponent != null && node.command() != null) {
                            child.command(node.command());
                        }
                    }
                }
                return CompletableFuture.completedFuture(child.command());
            } else if (child.isLeaf()) {
                final CommandComponent<C> rootComponent = root.component();
                if (rootComponent == null || root.command() == null) {
                    final List<CommandComponent<C>> components = Objects.requireNonNull(child.command()).components();
                    return CompletableFutures.failedFuture(
                            new InvalidSyntaxException(
                                    this.commandManager.commandSyntaxFormatter()
                                            .apply(commandContext.sender(), components, child),
                                    sender,
                                    this.getComponentChain(root)
                            )
                    );
                }

                final Command<C> command = root.command();
                final PermissionResult check = this.commandManager().testPermission(sender, command.commandPermission());
                if (check.allowed()) {
                    return CompletableFuture.completedFuture(command);
                }
                return CompletableFutures.failedFuture(
                        new NoPermissionException(
                                check,
                                sender,
                                this.getComponentChain(root)
                        )
                );
            } else {
                // The child is not a leaf, but may have an intermediary executor, attempt to use it
                final CommandComponent<C> rootComponent = root.component();
                if (rootComponent == null || root.command() == null) {
                    // Child does not have a command, and so we cannot proceed
                    return CompletableFutures.failedFuture(
                            new InvalidSyntaxException(
                                    this.commandManager.commandSyntaxFormatter()
                                            .apply(commandContext.sender(), parsedArguments, root),
                                    sender,
                                    this.getComponentChain(root)
                            )
                    );
                }

                // If the sender has permission to use the command, then we're completely done
                final Command<C> command = Objects.requireNonNull(root.command());
                final PermissionResult check = this.commandManager().testPermission(sender, command.commandPermission());
                if (check.allowed()) {
                    return CompletableFuture.completedFuture(command);
                }

                return CompletableFutures.failedFuture(
                        new NoPermissionException(
                                check,
                                sender,
                                this.getComponentChain(root)
                        )
                );
            }
        }

        final CommandComponent<C> component = Objects.requireNonNull(child.component());

        final CompletableFuture<?> parseResult;
        if (argumentValue != null) {
            if (argumentValue.parsedValue().isPresent()) {
                parseResult = CompletableFuture.completedFuture(argumentValue.parsedValue().get());
            } else {
                parseResult = CompletableFutures.failedFuture(this.argumentParseException(commandContext, child, argumentValue));
            }
        } else {
            parseResult = this.parseArgument(commandContext, child, commandInput, executor)
                    .thenApply(result -> result.parsedValue().orElse(null));
        }

        return parseResult.thenComposeAsync(value -> {
           if (value == null) {
               return CompletableFuture.completedFuture(null);
           }

           commandContext.store(component.name(), value);
           if (child.isLeaf()) {
               if (commandInput.isEmpty()) {
                   return CompletableFuture.completedFuture(child.command());
               }
               return CompletableFutures.failedFuture(
                       new InvalidSyntaxException(
                               this.commandManager.commandSyntaxFormatter()
                                       .apply(commandContext.sender(), parsedArguments, child),
                               sender,
                               this.getComponentChain(root)
                       )
               );
           }

            parsedArguments.add(Objects.requireNonNull(child.component()));
            return this.parseCommand(parsedArguments, commandContext, commandInput, child, executor);
        }, executor);
    }
Attempts to parse a command from the provided input.

@param commandContext  command context instance
@param commandInput    command input
@param parsingExecutor executor to schedule parsing logic on
@return parsed command, if one could be found
cloud-core/src/main/java/org/incendo/cloud/CommandTree.java