int (@Nullable Element e, boolean ignoreEmptyAttrValues) { if (e == null) return 0; int hashCode = e.getName().hashCode(); for (Attribute attribute : getAttributes(e)) { String value = attribute.getValue(); if (!ignoreEmptyAttrValues || (value != null && !value.isEmpty())) { hashCode = hashCode * 31 * 31 + attribute.getName().hashCode() * 31 + value.hashCode(); } } Iterator<Content> iterator = e.content().filter(CONTENT_FILTER).iterator(); while (iterator.hasNext()) { Content content = iterator.next(); int contentHash = content instanceof Element ? hashCode((Element)content, ignoreEmptyAttrValues) : e.getValue().hashCode(); hashCode = hashCode * 31 + contentHash; } return hashCode; }