In the sort order, Joomla is stored in the jos_categories table as a hierarchical tree structure with a set of related nodes. The columns used to set the order are parent_id , lft , rgt , and level .
Assets and menu items are saved in the same way.
You can learn more about Tree Walking on the wiki.
Edit:
Joomla 1.6 JCategoryNode :
jimport( 'joomla.application.categories' );
$extension = 'Content';
$options['countItems'] = true;
$categoryId = 0;
$categories = JCategories::getInstance($extension, $options);
$categories->get($categoryId);