How to hide No categories if there are no subcategories

Someone is using the put_cat_icons tag in order to display his categories and subcategories in archive.php. This presents a sizeable icon for each subcategory of the currently selected category. How to do this :

$cat = get_cat_ID( single_cat_title("", false) );
put_cat_icons( wp_list_categories('hide_empty=1&orderby=name&echo=0&depth=1&title_li=&child_of='.get_cat_ID( single_cat_title("", false) )));

The problem is that when there is no subcategory, “No categories” is displayed. So to hide this, we’ll use another filter this time, named wp_list_categories. Paste the following code in your functions.php file in your theme.

function bm_dont_display_it($content) {
  if (!empty($content)) {
    $content = str_ireplace('<li>' .__( "No categories" ). '</li>', "", $content);
  return $content;