List<Element> (final Element element, final Condition<? super Element> filter) { List<Element> toRemove = new ArrayList<>(); final List<Element> list = element.getChildren(); for (Element e : list) { if (filter.value(e)) { toRemove.add(e); } } for (Element e : toRemove) { element.removeContent(e); } return toRemove; }