Thank you for the above code, but it seems to work only on categories with up to max_category_nesting = 2 level.
Right now this code works on:
Parent
Parent > Sub
Not working for me with:
Grandparent > Parent > Sub
It does not break anything, it just gets applied up to default nesting (2) categories it seems.
Is there a way to modify it so it also works on max_category_nesting = 3?
Thanks!