boolean (List<? extends Element> l1, List<? extends Element> l2) { if (l1 == null) return l2 == null; if (l2 == null) return false; if (l1.size() != l2.size()) return false; Iterator<? extends Element> i1 = l1.iterator(); for (Element aL2 : l2) { Element elem1 = i1.next(); if (!elementsEqual(elem1, aL2)) return false; } return true; }