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