replacement of Category widget in WordPress e-Commerce

It took me several hours to understand that default e-Commerce category list widget is not working correctly, due to incorrect working of some core functions.

Jelouse Design posted a great article on replacing WPSC category list widget with the means of default WordPress functions – WP E-commerce Category list order and more control…

I needed to customize a little the code to suit my needs.
See the following:

This code gave me tree of categories, where current category has class ‘current-cat’