code: public static Map<String, Attribute> deepCopyAttributes(
        EntityType entityType, EntityType entityTypeCopy, AttributeFactory attrFactory) {
      Map<String, Attribute> copiedAttributes = new LinkedHashMap<>();
  
      // step #1: deep copy attributes
      Map<String, Attribute> ownAttrMap =
          stream(entityType.getOwnAllAttributes())
              .map(
                  attr -> {
                    Attribute attrCopy = Attribute.newInstance(attr, DEEP_COPY_ATTRS, attrFactory);
                    copiedAttributes.put(attr.getIdentifier(), attrCopy);
                    return attrCopy;
                  })
              .map(attrCopy -> attrCopy.setEntity(entityTypeCopy))
              .collect(toLinkedMap(Attribute::getName, Function.identity()));
  
      // step #2: update attribute.parent relations
      ownAttrMap.forEach(
          (attrName, ownAttr) -> {
            Attribute ownAttrParent = ownAttr.getParent();
            if (ownAttrParent != null) {
              ownAttr.setParent(ownAttrMap.get(ownAttrParent.getName()));
            }
          });
  
      entityTypeCopy.setOwnAllAttributes(ownAttrMap.values());
      return copiedAttributes;
    }
docs: Deep copy all attributes of an EntityType to its copy. Returns a LinkedMap of the old attribute
  IDs to the newly copied Attributes.
  
  @param entityType original entity meta data
  @param entityTypeCopy copy of entity meta data
  @param attrFactory attribute factory used to create new attributes in deep-copy mode
  @return map of old attributes IDs to copied attributes