added the n-ary tree code