Cast Spell @NPC Else Cast @Target

I’m trying to make a macro to benefit from rank 3 Breath of the Dying’s 100% increased damage it receives if it kills a unit. In arena, many players use the Twisted Appendage corruption which can conveniently be one-shot by Breath of the Dying.

Basically, I want a button that when pressed, will cast Breath of the Dying on any hostile Twisted Appendages in range, then target my last target, else cast Breath of the Dying on my target if no Twisted Appendages exist. Unfortunately, things haven’t worked smoothly, and I can’t quite figure out what I’m doing wrong. What I have so far:

/target Twisted Appendage
/targetlasttarget [noharm]
/cast Reaping Flames(Azerite Essence)
/stopmacro [exists]
/targetlasttarget

Unfortunately, the above doesn’t result in a smooth spammable button. We cant use conditionals on the first /target since conditionals apply to the current target which we have yet to acquire. We can’t use targetenemy because it doesn’t accept names. We also have to filter for friendly Twisted Appendages that may be present as well. We are assuming that I won’t have friendly players targeted since I play dps. We also want to make sure we are cycling through all Twisted Appendages if multiple are present in an area instead of just bouncing between my current target and the same Appendage, to ensure we arrive at an enemy Appendage that might be far away even if a friendly one is close.

/cleartarget
/targetexact Twisted Appendage
/targetlasttarget [noharm]
/cast Reaping Flames(Azerite Essence)
/stopmacro [harm,nodead]
/targetlasttarget

/cleartarget will clean up issues with /targetlasttarget producing undesired results.

Not possible while maintaining target fallback.

[update]