A tensorial theory of the higher-order constants of motion in quantum mechanics