Display top level category name by current category

Use the following code to display top label category name in magento navigations

<?php
$category = Mage::registry('current_category');
$it = 5; //Amount of iterations before script gives up
if ($category) {
while($category->getLevel() != 2 && --$it > 0) {
$category = $category->getParentCategory();
if (!($category instanceof Mage_Catalog_Model_Category)) {
break;
}
}
if ($category) {
echo $category->getName();
}
else {
echo 'Cannot find parent category';
}
}
?>