Don't reinvent the wheel, put them in a SQLite table, and let the sql engine create the tree for you!