public static void main ( String [ ] args ) {
  node root = new node ( 20 ) ;
  root . left = new node ( 10 ) ;
  root . right = new node ( 30 ) ;
  root . left . left = new node ( 5 ) ;
  root . left . right = new node ( 15 ) ;
  root . left . right . left = new node ( 12 ) ;
  root . right . left = new node ( 25 ) ;
  root . right . right = new node ( 40 ) ;
  int level = getLevel ( root , 30 ) ;
  if ( level != 0 ) System . out . println ( "level of node 30 is " + level ) ;
  else System . out . println ( "node 30 not found" ) ;
  level = getLevel ( root , 12 ) ;
  if ( level != 0 ) System . out . println ( "level of node 12 is " + level ) ;
  else System . out . println ( "node 12 not found" ) ;
  level = getLevel ( root , 25 ) ;
  if ( level != 0 ) System . out . println ( "level of node 25 is " + level ) ;
  else System . out . println ( "node 25 not found" ) ;
  level = getLevel ( root , 27 ) ;
  if ( level != 0 ) System . out . println ( "level of node 27 is " + level ) ;
  else System . out . println ( "node 27 not found" ) ;
}

public static void main ( String [ ] args ) { node root = new node ( 20 ) ; root . left = new node ( 10 ) ; root . right = new node ( 30 ) ; root . left . left = new node ( 5 ) ; root . left . right = new node ( 15 ) ; root . left . right . left = new node ( 12 ) ; root . right . left = new node ( 25 ) ; root . right . right = new node ( 40 ) ; int level = getLevel ( root , 30 ) ; if ( level != 0 ) System . out . println ( " level ▁ of ▁ node ▁ 30 ▁ is ▁ " + level ) ; else System . out . println ( " node ▁ 30 ▁ not ▁ found " ) ; level = getLevel ( root , 12 ) ; if ( level != 0 ) System . out . println ( " level ▁ of ▁ node ▁ 12 ▁ is ▁ " + level ) ; else System . out . println ( " node ▁ 12 ▁ not ▁ found " ) ; level = getLevel ( root , 25 ) ; if ( level != 0 ) System . out . println ( " level ▁ of ▁ node ▁ 25 ▁ is ▁ " + level ) ; else System . out . println ( " node ▁ 25 ▁ not ▁ found " ) ; level = getLevel ( root , 27 ) ; if ( level != 0 ) System . out . println ( " level ▁ of ▁ node ▁ 27 ▁ is ▁ " + level ) ; else System . out . println ( " node ▁ 27 ▁ not ▁ found " ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (decimal_integer_literal))))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (object_creation_expression type: (type_identifier) arguments: (argument_list (decimal_integer_literal))))) (expression_statement (assignment_expression left: (field_access object: (identifier) field: (identifier)) right: (object_creation_expression type: (type_identifier) arguments: (argument_list (decimal_integer_literal))))) (expression_statement (assignment_expression left: (field_access object: (field_access object: (identifier) field: (identifier)) field: (identifier)) right: (object_creation_expression type: (type_identifier) arguments: (argument_list (decimal_integer_literal))))) (expression_statement (assignment_expression left: (field_access object: (field_access object: (identifier) field: (identifier)) field: (identifier)) right: (object_creation_expression type: (type_identifier) arguments: (argument_list (decimal_integer_literal))))) (expression_statement (assignment_expression left: (field_access object: (field_access object: (field_access object: (identifier) field: (identifier)) field: (identifier)) field: (identifier)) right: (object_creation_expression type: (type_identifier) arguments: (argument_list (decimal_integer_literal))))) (expression_statement (assignment_expression left: (field_access object: (field_access object: (identifier) field: (identifier)) field: (identifier)) right: (object_creation_expression type: (type_identifier) arguments: (argument_list (decimal_integer_literal))))) (expression_statement (assignment_expression left: (field_access object: (field_access object: (identifier) field: (identifier)) field: (identifier)) right: (object_creation_expression type: (type_identifier) arguments: (argument_list (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (string_literal) right: (identifier))))) alternative: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (string_literal) right: (identifier))))) alternative: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (string_literal) right: (identifier))))) alternative: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (string_literal) right: (identifier))))) alternative: (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal)))))))