function cat_rows( $parent = 0, $level = 0, $categories = 0 ) {
	if (!$categories )
		$categories = get_categories( 'hide_empty=0' );

	$children = _get_category_hierarchy();

	if ( $categories ) {
		ob_start();
		foreach ( $categories as $category ) {
			if ( $category->category_parent == $parent) {
				echo "\t" . _cat_row( $category, $level );
				if ( isset($children[$category->cat_ID]) )
					cat_rows( $category->cat_ID, $level +1, $categories );
			}
		}
		$output = ob_get_contents();
		ob_end_clean();

		$output = apply_filters('cat_rows', $output);

		echo $output;
	} else {
		return false;
	}
}
 private static function Categories_box(&$data, $parent = 0, $level = 0, $categories = 0)
 {
     if (!$categories) {
         $categories = get_categories(array('hide_empty' => 0));
     }
     if (function_exists('_get_category_hierarchy')) {
         $children = _get_category_hierarchy();
     } elseif (function_exists('_get_term_hierarchy')) {
         $children = _get_term_hierarchy('category');
     } else {
         $children = array();
     }
     if ($categories) {
         ob_start();
         foreach ($categories as $category) {
             if ($category->parent == $parent) {
                 echo "\t" . self::_wpe_edit_cat_row($category, $level, $data);
                 if (isset($children[$category->term_id])) {
                     self::Categories_box($data, $category->term_id, $level + 1, $categories);
                 }
             }
         }
         $output = ob_get_contents();
         ob_end_clean();
         echo $output;
     } else {
         return false;
     }
 }
function &_get_cat_children($category_id, $categories) {
	if ( empty($categories) )
		return array();

	$category_list = array();
	$has_children = _get_category_hierarchy();

	if  ( ( 0 != $category_id ) && ! isset($has_children[$category_id]) )
		return array();

	foreach ( $categories as $category ) {
		if ( $category->cat_ID == $category_id )
			continue;

		if ( $category->category_parent == $category_id ) {
			$category_list[] = $category;

			if ( !isset($has_children[$category->cat_ID]) )
				continue;

			if ( $children = _get_cat_children($category->cat_ID, $categories) )
				$category_list = array_merge($category_list, $children);
		}
	}

	return $category_list;
}