/** * Returns true if this element is empty meaning all their attributes have default values and it * has no descendants. * * @return true if the element is empty, false otherwise */ private boolean isEmpty() { Map<String, String> attributesToWrite = attributesToWrite(); if (!attributesToWrite.isEmpty()) { return false; } // if we have children, we are not empty. return children.isEmpty(); }