Drupal : List all Categories

function _taxonomy_get_real_tree(){
$result_tree = array();
$terms = array();
$taxonomy = taxonomy_get_tree(1);
foreach($taxonomy as $term){
if(isset($terms[$term->tid])){
$term->children = $terms[$term->tid]->children;
$terms[$term->tid] = $term;
}else{
$terms[$term->tid] = $term;
}

if($term->depth === 0){
$result_tree[$term->tid] = &$terms[$term->tid];
continue;
}

foreach($term->parents as $tid){
if($tid){
if(!isset($terms[$tid])){
$terms[$tid] = new stdClass();
}
$terms[$tid]->children[$term->tid] = &$terms[$term->tid];
}
}
}
return $result_tree;
}