New efficient programs to calculate general recoupling coefficients. I: Generation of a summation formula. A program to generate a summation formula in terms of 6-$j$ coefficients for a general angular momentum recoupling coefficient is described. This algorithm makes use of binary tree transformations as introduced by {it P. G. Burke} [Comput. Phys. Commun. 1, 241 ff (1970)] in the program NJSYM. Due attention is paid to finding an optimal summation formula with a minimal number of summation variables, thereby improving the results of NJSYM. The results obtained here are at least as good as (and often better than) the results of the alternative approach NJGRAF, introduced by {it A. Bar-Shalom} and {it M. Klapisch} [Comput. Phys. Commun. 50, 375 ff (1988)], using more advanced graphical methods. For part II, see the review Zbl 891.17003 below.