one of the documented procedures in this installation of the ACS
database_to_tcl_tree   db   sql
What it does:
takes a 'connect by' SQL query and returns the result as a tree
Defined in: /web/philip/tcl/ad-trees.tcl

Source code:

    # Augment the SQL query by selecting the level.
    regsub select $sql "select level," sql
    # query the database
    set list [database_to_tcl_list_list $db $sql]
    # Construct a tree from the result.
    # Afterwards, eliminate the level attribute in the tree.
    tree_map tail [tree_make $list head]