static boolean dfs ( int u , int par , int [ ] h ) {
  boolean exist = ( h [ u ] == 1 ) ;
  for ( int v : g [ u ] ) {
    if ( v == par ) continue ;
    boolean child = dfs ( v , u , h ) ;
    if ( child ) res += 2 ;
    exist |= child ;
  }
  return exist ;
}

static boolean dfs ( int u , int par , int [ ] h ) { boolean exist = ( h [ u ] == 1 ) ; for ( int v : g [ u ] ) { if ( v == par ) continue ; boolean child = dfs ( v , u , h ) ; if ( child ) res += 2 ; exist |= child ; } return exist ; }
(method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (array_type element: (integral_type) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (array_access array: (identifier) index: (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (continue_statement)) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier))))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (return_statement (identifier))))