How Can Allow Adding Product Only Last Level Category?

Hi i want restrict adding product not last level categories, also i want show only last level categories during adding product categories selector, any idea?

I am afraid, CS-Cart does not have such logic in the fn_get_categories function