procedure ldag(stree,done)
local a
/done := table() # start table
# return list if done
if a := \done[stree] then return a
stree ? # build like a tree
if a := [tab(upto('('))] then {
move(1)
while put(a,ldag(tab(bal(',)')),done)) do
move(1)
}
else a := [tab(0)]
return done[stree] := a # put in table
end