You can use the simple Smart Search Filter webpart and attach it to a Smart Search Results repeater. In the filter choose a Dropdown as the filter type. Then create a new query which gets the categories and enter this as your text:
SELECT 'DocumentCategoryIDs', CategoryID, CategoryDisplayName FROM CMS_Category WHERE ##WHERE## ORDER BY ##ORDERBY##
Then in the WHERE enter this
CategoryEnabled = 1 and CategoryNamePath like '/YourParentCategoryName/%' and CategoryUserID is null AND (NOT EXISTS(SELECT CategoryID FROM CMS_Category AS pc WHERE (pc.CategoryEnabled = 0) AND (CMS_Category.CategoryIDPath like pc.CategoryIDPath+'/%')))
In the OrderBY set it like so:
CategoryLevel, CategoryOrder, CategoryDisplayName
Filter clause should equal "Must"
Check the "filter is conditional" box.
In the Smart Search Results repeater select a smart search index, if you don't have one, create one. Then make sure Block field-only search is unchecked, Search on each page load is checked, Search text required is unchecked and assign a transformation name.
This should get you what you need without needing to write any code.