PyType (@NotNull Collection<@Nullable PyType> members) { if (members.size() < 2) { return ContainerUtil.getFirstItem(members); } else { final LinkedHashSet<PyType> newMembers = new LinkedHashSet<>(); for (PyType member : members) { if (member instanceof PyUnionType) { newMembers.addAll(((PyUnionType)member).getMembers()); } else { newMembers.add(member); } } return newMembers.size() < 2 ? ContainerUtil.getFirstItem(newMembers) : new PyUnionType(newMembers); } }