public static long sum ( Queue < Node > queue , int x ) {
  long result = 0 ;
  boolean isRobotShutdown = false ;
  while ( ! queue . isEmpty ( ) ) {
    Node currNode = queue . remove ( ) ;
    if ( isRobotShutdown ) {
      result += currNode . y ;
      continue ;
    }
    if ( currNode . x % x == 0 ) {
      result += currNode . y ;
      currNode . x /= x ;
      queue . add ( currNode ) ;
    }
    else {
      result += currNode . y ;
      isRobotShutdown = true ;
    }
  }
  return result ;
}

public static long sum ( Queue < Node > queue , int x ) { long result = 0 ; boolean isRobotShutdown = false ; while ( ! queue . isEmpty ( ) ) { Node currNode = queue . remove ( ) ; if ( isRobotShutdown ) { result += currNode . y ; continue ; } if ( currNode . x % x == 0 ) { result += currNode . y ; currNode . x /= x ; queue . add ( currNode ) ; } else { result += currNode . y ; isRobotShutdown = true ; } } return result ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (generic_type (type_identifier) (type_arguments (type_identifier))) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (false))) (while_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (field_access object: (identifier) field: (identifier)))) (continue_statement))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (field_access object: (identifier) field: (identifier)))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (identifier))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (field_access object: (identifier) field: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (true))))))) (return_statement (identifier))))