  Quantum information needs to be protected by quantum error-correcting codes
due to imperfect quantum devices and operations. One would like to have an
efficient and high-performance decoding procedure for quantum codes. A
potential candidate is Pearl's belief propagation (BP), but its performance
suffers from the many short cycles inherent in quantum codes, especially
\textit{{highly-degenerate}} codes (that is, codes with many low-weight
stabilizers). A general impression exists that BP cannot work for topological
codes, such as the surface and toric codes. In this paper, we propose a
decoding algorithm for quantum codes based on quaternary BP but with additional
memory effects (called MBP). This MBP is like a recursive neural network with
inhibition between neurons (edges with negative weights) during recursion,
which enhances the network's perception capability. Moreover, MBP exploits the
degeneracy of quantum codes so that it has a better chance to find the most
probable error or its degenerate errors. The decoding performance is
significantly improved over the conventional BP for various quantum codes,
including quantum bicycle codes, hypergraph-product codes, and surface (or
toric) codes. For MBP on the surface and toric codes over depolarizing errors,
we observe thresholds of 14.5\%--16\% and 14.5\%--17.5\%, respectively.
