static @NotNull Element serialize(@NotNull Object object, @Nullable SerializationFilter filter) throws SerializationException {
    try {
      Class<?> aClass = object.getClass();
      Binding binding = serializer.getRootBinding(aClass, aClass);
      if (binding instanceof BeanBinding) {
        // top level expects not null (null indicates error, an empty element will be omitted)
        return Objects.requireNonNull(((BeanBinding)binding).serialize(object, true, filter));
      }
      else {
        //noinspection ConstantConditions
        return ((RootBinding)binding).serialize(object, filter);
      }
    }
    catch (SerializationException e) {
      throw e;
    }
    catch (Exception e) {
      throw new XmlSerializationException("Can't serialize instance of " + object.getClass(), e);
    }
  }
static @NotNull Element serialize(@NotNull Object object, @Nullable SerializationFilter filter)