toRetain.add(child);
toRetain.add(new Node());
toRetain.add("test");
assertFalse(elements.retainAll(toRetain));
toRetain.remove(child);
assertTrue(elements.retainAll(toRetain));
// Check if node was correctly detached from elements
assertEquals(0, elements.size());
assertNull(child.getParent());
assertNull(child.getDocument());