private @Nullable Ref<? extends PyType> getYieldStatementType(final @NotNull TypeEvalContext context) {
    final PyBuiltinCache cache = PyBuiltinCache.getInstance(this);
    final PyStatementList statements = getStatementList();
    final Set<PyType> types = new LinkedHashSet<>();
    statements.accept(new PyRecursiveElementVisitor() {
      @Override
      public void visitPyYieldExpression(@NotNull PyYieldExpression node) {
        final PyExpression expr = node.getExpression();
        final PyType type = expr != null ? context.getType(expr) : null;

        if (node.isDelegating()) {
          if (type instanceof PyCollectionType) {
            types.add(((PyCollectionType)type).getIteratedItemType());
          }
          else if (ArrayUtil.contains(type, cache.getListType(), cache.getDictType(), cache.getSetType(), cache.getTupleType())) {
            types.add(null);
          }
          else {
            types.add(type);
          }
        }
        else {
          types.add(type);
        }
      }

      @Override
      public void visitPyFunction(@NotNull PyFunction node) {
        // Ignore nested functions
      }
    });
    if (!types.isEmpty()) {
      final PyType elementType = PyUnionType.union(types);
      final PyType returnType = getReturnStatementType(context);
      return Ref.create(PyTypingTypeProvider.wrapInGeneratorType(elementType, returnType, this));
    }
    return null;
  }
private @Nullable Ref<? extends PyType> getYieldStatementType(final @NotNull TypeEvalContext context)