We provide a new algorithm for generating the Baker--Campbell--Hausdorff
(BCH) series Z = \log(\e^X \e^Y) in an arbitrary generalized Hall basis of
the free Lie algebra L(X,Y) generated by X and Y. It is based
on the close relationship of L(X,Y) with a Lie algebraic structure
of labeled rooted trees. With this algorithm, the computation of the BCH series
up to degree 20 (111013 independent elements in L(X,Y)) takes less
than 15 minutes on a personal computer and requires 1.5 GBytes of memory. We
also address the issue of the convergence of the series, providing an optimal
convergence domain when X and Y are real or complex matrices.Comment: 30 page