- let rec loop node acc =
- if node == T.nil then acc
- else
- let acc0 = loop (T.next_sibling tree node) acc in
- let acc1 = loop (T.first_child tree node) acc0 in
- if StateSet.intersect cache.(T.preorder tree node)
- sel_states then node::acc1
- else acc1
+ let res = ref (L.create ()) in
+ let rec loop node =
+ if node != T.nil then begin
+ if StateSet.intersect sel_states cache.(T.preorder tree node) then
+ res := L.add node !res;
+ loop (T.first_child tree node);
+ loop (T.next_sibling tree node)
+ end