TreeWalker { public void add(RootCommandNode<R> root, Collection<? extends CommandNode<T>> commands, T source, Predicate<CommandNode<T>> requirement) { for (var command : commands) { if (requirement.test(command)) { var result = map(command, source); if (result != null) { root.addChild(result); } } } mappings.clear(); } TreeWalker(Mapper<T, R> mapper); void prune(RootCommandNode<R> root, Collection<? extends CommandNode<T>> commands); void add(RootCommandNode<R> root, Collection<? extends CommandNode<T>> commands, T source, Predicate<CommandNode<T>> requirement);  }
@Test void add() { root.addChild(Literal.<String>builder("a").then(Literal.<String>builder("child").build()).build()); tree.add(root, commands, "", command -> !command.getName().equalsIgnoreCase("b")); assertEquals(1, root.getChildren().size()); assertNotNull(root.getChild("a").getChild("child")); }