Solved with the following:
$args = array(
'orderby' => 'name',
'parent' => 0
);
$categories = get_categories( $args );
$first = true;
foreach ($categories as $category) {
if ( $first )
{
echo '<li class="title" style="border-top: 0px;"><a href="https://wordpress.stackexchange.com/questions/116483/acatalog/abovegroundpools.html">'.$category->cat_name.'</a>';
$first = false;
}
else
{
echo '<li class="title"><a href="https://wordpress.stackexchange.com/questions/116483/acatalog/abovegroundpools.html">'.$category->cat_name.'</a>';
}
$theid = $category->term_id;
$children = $wpdb->get_results( "SELECT term_id FROM $wpdb->term_taxonomy WHERE parent=$theid" );
$no_children = count($children);
if ($no_children > 0) {
echo "<ul>";
$args2 = array(
'orderby' => 'name',
'parent' => 2
);
$args2["parent"]=$category->term_id;
$categories2 = get_categories( $args2 );
foreach ($categories2 as $category2) {
echo '<li><a href="acatalog/Inflatable-Hot-Tubs.html">'.$category2->cat_name.'</a></li>';
}
echo '</ul>';
} else {
echo '</li>';
}
}
?>