TreeVisitor (String parentPath, Predicate<? super PackagingElementNode<?>> childFilter) { List<Predicate<PackagingElementNode<?>>> parentElementFilters = ContainerUtil.map(StringUtil.split(parentPath, "/"), LayoutTree::createCompositeNodeByNameFilter); TreePath predicatesPath = TreePathUtil.convertCollectionToTreePath(ContainerUtil.append(parentElementFilters, childFilter)); return new TreeVisitor.ByTreePath<PackagingElementNode<?>>(true, predicatesPath, node -> TreeUtil.getUserObject(PackagingElementNode.class, node)) { @Override protected boolean matches(@NotNull PackagingElementNode<?> pathComponent, @NotNull Object thisComponent) { //noinspection unchecked return thisComponent instanceof Predicate && ((Predicate<PackagingElementNode<?>>)thisComponent).test(pathComponent); } }; }