Object (@NotNull Object context, @NotNull List<XmlElement> elements) { List<XmlElement> children; if (elements.size() == 1) { children = elements.get(0).children; } else { String name = elements.get(0).name; children = new ArrayList<>(); for (XmlElement element : elements) { assert element.name.equals(name); children.addAll(element.children); } } deserialize2(context, children); return context; }