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