 ! Copyright (C) 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors db.tuples kernel new-slots semantic-db
-semantic-db.relations sorting sequences sequences.deep ;
+USING: accessors db.tuples hashtables kernel new-slots
+semantic-db semantic-db.relations sorting sequences ;
 IN: semantic-db.hierarchy
 
 TUPLE: tree id children ;

: get-node-hierarchy ( node-id -- tree )
    dup children [ get-node-hierarchy ] map <tree> ;

: uniq ( sorted-seq -- seq )
    f swap [ tuck = not ] subset nip ;

: (get-root-nodes) ( node-id -- root-nodes/node-id )
    dup parents dup empty? [
        drop

    ] if ;

: get-root-nodes ( node-id -- root-nodes )
    (get-root-nodes) flatten prune ;
