boolean (Element o1, Element o2) { if (o1 instanceof ImmutableElement) { return ((ImmutableElement)o1).attributesEqual(o2); } if (o2 instanceof ImmutableElement) { return ((ImmutableElement)o2).attributesEqual(o1); } List<Attribute> a1 = JDOMUtil.getAttributes(o1); List<Attribute> a2 = JDOMUtil.getAttributes(o2); if (a1.size() != a2.size()) return false; for (int i=0; i<a1.size(); i++) { Attribute attr1 = a1.get(i); Attribute attr2 = a2.get(i); if (!ImmutableElement.attributesEqual(attr1, attr2)) return false; } return true; }