code: public static SoyType of(Collection<SoyType> members) {
      // sort and flatten the set of types
      ImmutableSortedSet.Builder<SoyType> builder = ImmutableSortedSet.orderedBy(MEMBER_ORDER);
      for (SoyType type : members) {
        // simplify unions containing these types
        if (type.getKind() == Kind.UNKNOWN
            || type.getKind() == Kind.ERROR
            || type.getKind() == Kind.ANY) {
          return type;
        }
        if (type.getKind() == Kind.UNION) {
          builder.addAll(((UnionType) type).members);
        } else {
          builder.add(type);
        }
      }
      ImmutableSet<SoyType> flattenedMembers = builder.build();
      if (flattenedMembers.size() == 1) {
        return Iterables.getOnlyElement(flattenedMembers);
      }
      return new UnionType(flattenedMembers);
    }
docs: Create a union from a collection of types.
  
  @param members Member types of the union.
  @return Union of those types. If there is exactly one distinct type in members, then this will
  not be a UnionType.