here is a solution, but again, you have to know how many levels you want to return –
Categories and Subcategories