add procedure count-leaves with accumulate