private void visitIfStatementNode(AstNode node) {
   if (checkedIfStatements.contains(node)) {
     return;
   }
   List<AstNode> branchNodes = Lists.newArrayList();
   AstNode ifNode = node;
   while (ifNode != null) {
     checkedIfStatements.add(ifNode);
     branchNodes.add(ifNode.getFirstChild(ifBranchNodeType()));
     AstSelect elseIfNodes =
         ifNode
             .select()
             .children(PHPGrammar.ELSEIF_LIST)
             .children(PHPGrammar.ELSEIF_CLAUSE)
             .children(ifBranchNodeType());
     for (AstNode condition : elseIfNodes) {
       branchNodes.add(condition);
     }
     AstSelect elseNodes = ifNode.select().children(PHPGrammar.ELSE_CLAUSE);
     for (AstNode elseNode : elseNodes.children(ifBranchNodeType())) {
       branchNodes.add(elseNode);
     }
     AstSelect elseIfs =
         elseNodes.children(PHPGrammar.STATEMENT).children(PHPGrammar.IF_STATEMENT);
     ifNode = elseIfs.isEmpty() ? null : elseIfs.get(0);
   }
   checkBranches(branchNodes, "branch");
 }
 private static List<Token> getFieldNameTokens(AstNode astNode) {
   List<Token> methodNames = new LinkedList<>();
   AstSelect funcDefSelect =
       astNode
           .select()
           .children(PythonGrammar.SUITE)
           .children(PythonGrammar.STATEMENT)
           .children(PythonGrammar.COMPOUND_STMT)
           .children(PythonGrammar.FUNCDEF);
   for (AstNode node : funcDefSelect) {
     methodNames.add(node.getFirstChild(PythonGrammar.FUNCNAME).getToken());
   }
   return methodNames;
 }
  private static boolean hasAnnotationDifferentFromOverride(AstNode node) {
    AstSelect query =
        node.select()
            .firstAncestor(JavaGrammar.CLASS_BODY_DECLARATION)
            .children(JavaGrammar.MODIFIER)
            .children(JavaGrammar.ANNOTATION)
            .children(JavaGrammar.QUALIFIED_IDENTIFIER);

    for (AstNode qualifiedIdentifier : query) {
      if (!isOverride(qualifiedIdentifier)) {
        return true;
      }
    }

    return false;
  }
  @Override
  public void visitNode(AstNode suiteNode) {
    if (suiteNode.getParent().is(PythonGrammar.FUNCDEF, PythonGrammar.CLASSDEF)
        || isInExcept(suiteNode)) {
      return;
    }

    AstSelect suite = suiteNode.select();
    AstSelect stmtLists = suite.children(PythonGrammar.STMT_LIST);
    if (stmtLists.isEmpty()) {
      AstSelect statementSelect = suite.children(PythonGrammar.STATEMENT);
      if (statementSelect.children(PythonGrammar.COMPOUND_STMT).isNotEmpty()) {
        return;
      }
      stmtLists = statementSelect.children(PythonGrammar.STMT_LIST);
    }

    AstSelect nonPassSimpleStatements =
        stmtLists.children(PythonGrammar.SIMPLE_STMT).children().filter(NOT_PASS_PREDICATE);
    if (nonPassSimpleStatements.isEmpty() && !containsComment(suiteNode)) {
      getContext().createLineViolation(this, MESSAGE, stmtLists.get(0));
    }
  }
 private void visitCaseListNode(AstNode node) {
   AstSelect conditions =
       node.select().children(PHPGrammar.CASE_CLAUSE).children(caseClauseChildType());
   checkBranches(ImmutableList.copyOf(conditions), "case");
 }