1 2 3 4 5
import Tree countLeaves Empty = 0 countLeaves (Branch _ Empty Empty) = 1 countLeaves (Branch _ t1 t2) = countLeaves t1 + countLeaves t2