Does anything exist ( like a macro or add on ) to target and cast a spell at the target who have a specific debuff? ?

The best would be a macro with which I could cast a spell on my target, and a macro line that when there is the debuff on an other target, it will switch to it.

Is it possible with something?

Thanks a lot !