Element (@NotNull List<? extends HtmlChunk> chunks) { if (myChildren.isEmpty()) { return new Element(myTagName, myAttributes, new ArrayList<>(chunks)); } List<HtmlChunk> newChildren = new ArrayList<>(myChildren.size() + chunks.size()); newChildren.addAll(myChildren); newChildren.addAll(chunks); return new Element(myTagName, myAttributes, newChildren); }