How can I avoid Gimble lock when adding 2 rotators

There is a method to do it using Quats. But I am not sure how is it done.