Check if current category has subcategories

I have found the following piece of code in the WP Knowledge Base theme in order to show subcategories of a parent category. The problem is that this only works for the first level of hierarchy, so I wanted to change the if clause in order to check if the current category has children but I have no clue how to do that, any idea?
Thanks