static boolean CheckChildrenSum ( Node root ) {
  Queue < Node > q = new LinkedList < Node > ( ) ;
  q . add ( root ) ;
  while ( q . size ( ) > 0 ) {
    Node temp = q . peek ( ) ;
    q . remove ( ) ;
    if ( temp . left != null && temp . right != null ) {
      if ( temp . data != temp . left . data + temp . right . data ) return false ;
      q . add ( temp . left ) ;
      q . add ( temp . right ) ;
    }
    else if ( temp . left == null && temp . right != null ) {
      if ( temp . data != temp . right . data ) return false ;
      q . add ( temp . right ) ;
    }
    else if ( temp . right == null && temp . left != null ) {
      if ( temp . data != temp . left . data ) return false ;
      q . add ( temp . left ) ;
    }
  }
  return true ;
}

static boolean CheckChildrenSum ( Node root ) { Queue < Node > q = new LinkedList < Node > ( ) ; q . add ( root ) ; while ( q . size ( ) > 0 ) { Node temp = q . peek ( ) ; q . remove ( ) ; if ( temp . left != null && temp . right != null ) { if ( temp . data != temp . left . data + temp . right . data ) return false ; q . add ( temp . left ) ; q . add ( temp . right ) ; } else if ( temp . left == null && temp . right != null ) { if ( temp . data != temp . right . data ) return false ; q . add ( temp . right ) ; } else if ( temp . right == null && temp . left != null ) { if ( temp . data != temp . left . data ) return false ; q . add ( temp . left ) ; } } return true ; }
(method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (while_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (null_literal)) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (null_literal)))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (binary_expression left: (field_access object: (field_access object: (identifier) field: (identifier)) field: (identifier)) right: (field_access object: (field_access object: (identifier) field: (identifier)) field: (identifier))))) consequence: (return_statement (false))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (null_literal)) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (null_literal)))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (field_access object: (identifier) field: (identifier)) field: (identifier)))) consequence: (return_statement (false))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (null_literal)) right: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (null_literal)))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (field_access object: (field_access object: (identifier) field: (identifier)) field: (identifier)))) consequence: (return_statement (false))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier))))))))))) (return_statement (true))))