Cache categories tree in template.

Categories tree can be cached to improve a bit page loading.