Look at the module named Simple Category Tree under my sig.
You may need to add a few lines of code to do exactly what you want.