Perl implementation of N-ary search trees