public PackagingElementEntity.Builder<? extends PackagingElementEntity> getOrAddEntityBuilder(@NotNull MutableEntityStorage diff,
                                                                                                @NotNull EntitySource source,
                                                                                                @NotNull Project project) {
    PackagingElementEntity existingEntity = (PackagingElementEntity)getExistingEntity(diff);
    if (existingEntity != null) return getBuilder(diff, existingEntity);

    S state = this.getState();
    String xmlTag = "";
    if (state != null) {
      xmlTag = JDOMUtil.write(XmlSerializer.serialize(state));
    }

    List<PackagingElementEntity.Builder<? extends PackagingElementEntity>> children = new ArrayList<>();
    if (this instanceof CompositePackagingElement<?>) {
      children.addAll(
        ContainerUtil.map(((CompositePackagingElement<?>)this).getChildren(), o -> o.getOrAddEntityBuilder(diff, source, project))
      );
    }

    CustomPackagingElementEntity addedEntity =
      diff.addEntity(CustomPackagingElementEntity.create(this.getType().getId(), xmlTag, source, builder -> {
        builder.setChildren(children);
        return Unit.INSTANCE;
      }));

    diff.getMutableExternalMapping(PackagingExternalMapping.key).addMapping(addedEntity, this);
    return getBuilder(diff, addedEntity);
  }
public PackagingElementEntity.Builder<? extends PackagingElementEntity> getOrAddEntityBuilder(@NotNull MutableEntityStorage diff,
                                                                                                @NotNull EntitySource source,
                                                                                                @NotNull Project project)