A theoretical study of the mechanism for the homogeneous catalytic reversible dehydrogenation-hydrogenation of nitrogen heterocycles.