@Nullable
  private static PsiType inferLoopParameterTypeWithNullability(PsiForeachStatement loop) {
    PsiExpression iteratedValue = PsiUtil.skipParenthesizedExprDown(loop.getIteratedValue());
    if (iteratedValue == null) return null;

    PsiType iteratedType = iteratedValue.getType();
    if (iteratedValue instanceof PsiReferenceExpression refExpr && 
        refExpr.resolve() instanceof PsiParameter parameter &&
        parameter.getParent() instanceof PsiForeachStatement targetLoop &&
        PsiTreeUtil.isAncestor(targetLoop, loop, true) &&
        !HighlightControlFlowUtil.isReassigned(parameter, new HashMap<>())) {
      iteratedType = inferLoopParameterTypeWithNullability(targetLoop);
    }
    return JavaGenericsUtil.getCollectionItemType(iteratedType, iteratedValue.getResolveScope());
  }
@Nullable
  private static PsiType inferLoopParameterTypeWithNullability(PsiForeachStatement loop)