Is there a way to return nodes based on id

I have created a tree from a mySQL table.

From the ID is there a way to return all the ID’s back to the root (first ID) so it returns a list:

0,1,2,3,8

There is a method getParentId()
docs.dhtmlx.com/doku.php?id=dhtm … etparentid
You just get all the ids untill you’ll get the root ID ‘0’ and replace the order of this list items.