static boolean isVariableSuitableForStream(PsiVariable variable, PsiStatement statement, TerminalBlock tb) {
    PsiElement block = PsiUtil.getVariableCodeBlock(variable, statement);
    if (block != null) {
      Predicate<PsiElement> notAllowedWrite = e -> e instanceof PsiReferenceExpression ref && 
                                                   PsiUtil.isAccessedForWriting(ref) &&
                                                   ref.isReferenceTo(variable) &&
                                                   tb.operations().noneMatch(op -> op.isWriteAllowed(variable, ref));
      if (PsiTreeUtil.processElements(block, notAllowedWrite.negate()::test)) return true;
    }
    return HighlightControlFlowUtil.isEffectivelyFinal(variable, statement, null);
  }
static boolean isVariableSuitableForStream(PsiVariable variable, PsiStatement statement, TerminalBlock tb)