  Hierarchical mergers are one of the distinctive signatures of binary black
hole (BBH) formation through dynamical evolution. Here, we present a fast
semi-analytic approach to simulate hierarchical mergers in nuclear star
clusters (NSCs), globular clusters (GCs) and young star clusters (YSCs).
Hierarchical mergers are more common in NSCs than they are in both GCs and
YSCs, because of the different escape velocity. The mass distribution of
hierarchical BBHs strongly depends on the properties of first-generation BBHs,
such as their progenitor's metallicity. In our fiducial model, we form black
holes (BHs) with masses up to $\sim{}10^3$ M$_\odot$ in NSCs and up to
$\sim{}10^2$ M$_\odot$ in both GCs and YSCs. When escape velocities in excess
of 100 km~s$^{-1}$ are considered, BHs with mass $>10^3$ M$_\odot$ are allowed
to form in NSCs. Hierarchical mergers lead to the formation of BHs in the pair
instability mass gap and intermediate-mass BHs, but only in metal-poor
environments. The local BBH merger rate in our models ranges from $\sim{}10$ to
$\sim{} 60$ Gpc$^{-3}$ yr$^{-1}$; hierarchical BBHs in NSCs account for
$\sim{}10^{-2}- 0.2$ Gpc$^{-3}$ yr$^{-1}$, with a strong upper limit of
$\sim{}10$ Gpc$^{-3}$ yr$^{-1}$. When comparing our models with the second
gravitational-wave transient catalog, we find that multiple formation channels
are favored to reproduce the observed BBH population.
