How do I find all the paths from a specific node (node 36 in the example)?
Let's say we have two tables:
CATEGORIES CATEG_PARENTS
id idc | idparent
-- ----------------
1 2 1
2 2 20
5 5 2
8 8 5
20 20 1
22 22 8
30 22 20
31 30 20
36 31 22
31 30
36 31
These are two possible representations:

This is the output I desire:
ids
-------------------
"{1,20,22,31}"
"{1,20,2,5,8,22,31}"
"{1,20,30,31}"
"{1,2,5,8,22,31}"
One path per line, written as an integer array.
(I'm going to write the answer I came up with, but I'll accept any that's simpler, if any)