MaxLength of tree