with Tree as (
/* base query */
select root.id as id, root.text as text, 0 as level from Node root where root.parent is null
union
/* recursion */
select child.id as id, child.text as text, parent.level+1 as level from Tree parent join Node child on child.parent.id = parent.id
)
search breadth first by id set depth
cycle id set abort to "aborted!" default "" using path1
select t
from Tree as t
order by depth asc