On top of the currently available options when choosing delete behaviour for an association, add an option to
“On delete of ‘X’ object → Delete ‘X’ object only if selected microflow returns true”
and then be able to select a microflow with return type boolean.
This way you can prevent or allow deletion in much more specific cases than just “only if it is not associated with ‘Y’ object(s)”.