radio button matrix in a checkbox tree

I would like my users to toggle opt-in or opt-out the nested items in my checkbox tree individually but also toggle them all opt-in or all opt-out at once. In my example, I use radio buttons. But the problem is that for the all opt-in or out toggle there is no such thing as a mixed state with radio buttons like there is with checkboxes. On the other hand, checkboxes can check all opt-in AND out. Which would mean that all nested items could be both on and off and that's not what I would want.

matrix radio buttons inside a checkbox tree

Other variants I've made: enter image description here

enter image description here