I remember when years ago and i still was fresh to this i was searching like a function like this all the time and trying to make one without much success. 
I guess i was over thinking all the loops at the time, guess i got a lil smarter with the years. xD cause it's really simple. 
Anyways this lists all sub-directories of a specified folder. 
[Edit] Don't be silly and try to scan your entire hdd it will take ages. it's not meant for huge file structures. 
Functions: 
    
Example: 
    
UDF: