int (@Nullable PyType type) { int result = 1; if (type instanceof PyUnionType pyUnionType) { for (PyType member : pyUnionType.getMembers()) { result += countTypes(member); } } else if (type instanceof PyCollectionType pyCollectionType) { for (PyType member : pyCollectionType.getElementTypes()) { result += countTypes(member); } } return result; }