Checks if current node is not null and doesn 't have any children
if ( root . children != null && root . children . size ( ) == 0 ) { ans = Math . max ( ans , root . val ) ; return new double [ ] { root . val , 1 } ; }