UExpression (@NotNull UExpression expression, boolean stopAtCall) { while (expression.getUastParent() instanceof UExpression parent) { if (parent instanceof UBlockExpression || parent instanceof UReturnExpression) { break; } if (parent instanceof UIfExpression && UastUtils.isPsiAncestor(((UIfExpression)parent).getCondition(), expression)) { break; } expression = parent; if (UastExpressionUtils.isAssignment(expression)) break; if (expression instanceof UCallExpression && stopAtCall) { UastCallKind kind = ((UCallExpression)expression).getKind(); if (kind == UastCallKind.METHOD_CALL) { if (expression.getUastParent() instanceof UQualifiedReferenceExpression) { expression = (UExpression)expression.getUastParent(); } break; } } } return expression; }