ASTNode (@Nullable ASTNode forStatement) { if (!is(forStatement, BASIC_FOR_STATEMENT)) { return null; } ASTNode initialization = findChildByType(forStatement, STATEMENT_SET); if (initialization == null) { return null; } // should be inside parens ASTNode paren = getLParenth(forStatement); if (paren == null) { return null; } for (ASTNode child = paren; child != null; child = child.getTreeNext()) { if (child == initialization) return initialization; if (is(child, RPARENTH)) return null; } return null; }