  In this work, we preform a systematic investigation about hidden heavy and
doubly heavy molecular states from the
$D^{(*)}\bar{D}^{(*)}/B^{(*)}\bar{B}^{(*)}$ and
$D^{(*)}D^{(*)}/\bar{B}^{(*)}\bar{B}^{(*)}$ interactions in the quasipotential
Bethe-Salpeter equation (qBSE) approach. With the help of Lagrangians with
heavy quark and chiral symmetries, interaction potentials are constructed
within the one-boson-exchange model in which we include the $\pi$, $\eta$,
$\rho$, $\omega$ and $\sigma$ exchanges, as well as $J/\psi$ or $\Upsilon$
exchange. Possible bound states from the interactions considered are searched
for as the pole of scattering amplitude. The results suggest that
experimentally observed states, $Z_c(3900)$, $Z_c(4020)$, $Z_b(10610)$, and
$Z_b(10650)$, can be related to the $D\bar{D}^{*}$, $D^*\bar{D}^{*}$,
$B\bar{B}^{*}$, and $B^*\bar{B}^{*}$ interactions with quantum numbers
$I^G(J^P)=1^+(1^{+})$, respectively. The $D\bar{D}^{*}$ interaction is also
attractive enough to produce a pole with $0^+(0^+)$ which is related to the
$X(3872)$. Within the same theoretical frame, the existence of $D\bar{D}$ and
$B\bar{B}$ molecular states with $0(0^+)$ are predicted. The possible
$D^*\bar{D}^*$ molecular states with $0(0^+, 1^+, 2^+)$ and $1(0^+)$ and their
bottom partners are also suggested by the calculation. In the doubly heavy
sector, no bound state is produced from the $DD/\bar{B}\bar{B}$ interaction
while a bound state is found with $0(1^+)$ from $DD^*/\bar{B}\bar{B}^*$
interaction. The $D^*D^*/\bar{B}^*\bar{B}^*$ interaction produces three
molecular states with $0(1^+)$, $0(2^+)$ and $1(2^+)$.
