magento2.3 – assign only one and leaf category per product in magento 2.3.3

I want that the only category checkbox selectable should be the leaf category that is the category checkbox without children in the current branch and only one category checkbox per product can be selected.
The pseudo code is:

if category has children then input checkbox tag is disabled
if at least one category is selected then disable all other checkboxes

I can’t find where to edit the category checkboxes code.
They are the checlboxes shown in the product edit page or new product page.