Parts of the tree with “don’t merge children” might be ok, then you show the user a conflict dialog when this happens.
Or, inspired by your comment: run f for the tree, if false, search for the smallest subset where f is false and show the conflict dialog for that. The user
chooses “mine” or “theirs”.