saving the work
half pass at countTree function
calculates total nodes in a K-ary tree