boolean (@NotNull GrStatement containingStatement,@NotNull GrStatement statement) { GroovyPsiElement statementToCheck = statement; while (true) { if (statementToCheck.equals(containingStatement)) { return true; } final GroovyPsiElement container = getContainingStatement(statementToCheck); if (container == null) { return false; } if (container instanceof GrBlockStatement) { if (!statementIsLastInBlock((GrBlockStatement)container, (GrStatement)statementToCheck)) { return false; } } if (isLoop(container)) { return false; } statementToCheck = container; } }