code: private void findProtoTypesRecurse(SoyType type, SortedSet<String> protoTypes) {
      switch (type.getKind()) {
        case PROTO:
          protoTypes.add(((SoyProtoType) type).getDescriptorExpression());
          break;
  
        case PROTO_ENUM:
          protoTypes.add(((SoyProtoEnumType) type).getDescriptorExpression());
          break;
  
        case UNION:
          for (SoyType member : ((UnionType) type).getMembers()) {
            findProtoTypesRecurse(member, protoTypes);
          }
          break;
  
        case LIST:
          {
            ListType listType = (ListType) type;
            findProtoTypesRecurse(listType.getElementType(), protoTypes);
            break;
          }
  
        case MAP:
        case LEGACY_OBJECT_MAP:
          {
            AbstractMapType mapType = (AbstractMapType) type;
            findProtoTypesRecurse(mapType.getKeyType(), protoTypes);
            findProtoTypesRecurse(mapType.getValueType(), protoTypes);
            break;
          }
  
        case RECORD:
          {
            RecordType recordType = (RecordType) type;
            for (SoyType fieldType : recordType.getMembers().values()) {
              findProtoTypesRecurse(fieldType, protoTypes);
            }
            break;
          }
        case VE:
          {
            VeType veType = (VeType) type;
            if (veType.getDataType().isPresent()) {
              // Don't grab the proto type for ve<null>
              SoyType soyType = typeRegistry.getType(veType.getDataType().get());
              if (soyType.getKind() == Kind.PROTO) {
                protoTypes.add(((SoyProtoType) soyType).getDescriptorExpression());
              }
            }
            break;
          }
  
        case ANY:
        case UNKNOWN:
        case ERROR:
        case NULL:
        case BOOL:
        case INT:
        case FLOAT:
        case STRING:
        case HTML:
        case ATTRIBUTES:
        case JS:
        case CSS:
        case URI:
        case TRUSTED_RESOURCE_URI:
        case VE_DATA:
          // continue
      }
    }
docs: Recursively search for protocol buffer types within the given type.
  
  @param type The type to search.
  @param protoTypes Output set.