ASTNode (@NotNull ASTNode element) { ASTNode statement = BasicJavaAstTreeUtil.getParentOfType(element, ParentAwareTokenSet.create(BASIC_FOREACH_STATEMENT, BASIC_FOR_STATEMENT, BASIC_WHILE_STATEMENT)); if (statement == null) return null; if (BasicJavaAstTreeUtil.is(statement, BASIC_FOREACH_STATEMENT)) { return isForEachApplicable(statement, element) ? statement : null; } if (BasicJavaAstTreeUtil.is(statement, BASIC_FOR_STATEMENT)) { return isForApplicable(statement, element) ? statement : null; } if (BasicJavaAstTreeUtil.is(statement, BASIC_WHILE_STATEMENT)) { return statement; } return null; }