count_terminal_nodes function

Counts the number of terminal nodes (merging 0 nodes!)