A node for ComfyUI that takes a list of masks and returns a single mask based on your criteria.
https://github.com/SparknightLLC/ComfyUI-ConditionalInterrupt
git clone https://github.com/SparknightLLC/ComfyUI-ConditionalInterrupt
comfy node install comfyui-conditionalinterrupt