void (@NotNull HierarchyTreeStructure treeStructure, @NotNull HierarchyNodeDescriptor descriptor, @NotNull Element element, @Nullable Comparator<? super NodeDescriptor<?>> comparator) { if (element.getChild(ANY_NODES_ELEMENT_NAME) != null) { return; } Object[] children = getSortedChildren(treeStructure, descriptor, comparator); List<Element> expectedChildren = new ArrayList<>(element.getChildren(NODE_ELEMENT_NAME)); StringBuilder messageBuilder = new StringBuilder("Actual children of [" + descriptor.getHighlightedText().getText() + "]:\n"); for (Object child : children) { HierarchyNodeDescriptor nodeDescriptor = (HierarchyNodeDescriptor)child; nodeDescriptor.update(); messageBuilder.append(" [").append(nodeDescriptor.getHighlightedText().getText()).append("]\n"); } assertEquals(messageBuilder.toString(), expectedChildren.size(), children.length); Arrays.sort(children, Comparator.comparing(child -> ((HierarchyNodeDescriptor)child).getHighlightedText().getText())); expectedChildren.sort(Comparator.comparing(child -> child.getAttributeValue(TEXT_ATTR_NAME))); Iterator<Element> iterator = expectedChildren.iterator(); for (Object child : children) { checkNodeDescriptorRecursively(treeStructure, (HierarchyNodeDescriptor)child, iterator.next(), comparator); } }