删除supersub类别PHP Mysql中的链接

I have a problem with active link that i've created. I want to make the Sub Category doesn't have any link, only the supersub have link for each supersub category.

The example like: 1. painting (category), 1.1 HOBE (sub category), 1.1.1 Sealer, 1.1.2 Wall Paint (supersub category)

The table contain: id_kategori, kategori, id_parent

This is my code:

<?php
include "config.php";

function punya_child($id_kategori = NULL)
{
$result = mysql_query('SELECT COUNT(id_kategori) AS jumlah_child FROM category WHERE id_parent = \''.$id_kategori.'\'');
$data = mysql_fetch_assoc($result);
if($data['jumlah_child'] > 0) return TRUE;    
return FALSE;
}

function hirarki($id_kategori = NULL)
{
   if($id_kategori === NULL)
   {
    $result_top_level = mysql_query('SELECT * FROM category WHERE id_parent IS NULL');        
    if(mysql_num_rows($result_top_level) > 0)
    {
        echo '<ul class="category">';            
        while($row_top_level = mysql_fetch_assoc($result_top_level))
        {
            echo "<li class='category'>", $row_top_level['kategori'];                
            if(punya_child($row_top_level['id_kategori']))
            {
                hirarki($row_top_level['id_kategori']);
            }                
            echo '</li>';
        }            
        echo '</ul>';
    }
}
else
{
    $result_child = mysql_query('SELECT * FROM category WHERE id_parent = \''.$id_kategori.'\'');    
    if(mysql_num_rows($result_child) > 0)
    {
        echo '<ul class="subcategory">';        
        while($row_child = mysql_fetch_assoc($result_child))
        {
            echo "<li><a href='cat.php?kategori=$row_child[kategori]'>", $row_child['kategori'];
            if(punya_child($row_child['id_kategori']))
            {
                hirarki($row_child['id_kategori']);
            }            
            echo '</li>';
        }    
        echo '</ul></a>';
    }
}
}
hirarki();
?>

I really thankful if someone can help me how solve this problem. Thank you