MDL-40297 Hide empty categories in my courses

This is a followup of MDL-38631 were was detected that
whith categories being displayed in my courses, some of
them, not having courses for the user, were still shown.

With this patch, any category in the tree, not having courses
is automatically hidden, any depth.
MDL-40297 whitespace, comments & var names cleanup