Is there a way to treat hyperventilation?

Yes. If you are breathing too fast for no physiologic reason, such as for fever or vigorous exercise, then breathing into a paper bag would be helpful.
Biofeedback. Usually with simple recognization that one is hyperventilating and either performing biofeedback techniques to get oneself to stop hyperventilating.