I've been stuck on a similar problem, it might not completely fit your situation, but perhaps it can give you an insight on the loop implementation you need to use (not limited to the number of levels)
Can you get the objects as a delimited string (a "path")? For example storeName.catName.stockName
If so, you could use the follow code, or at least the loop implementation by first filling a list with each row of data you got, and then passing it through a sortlike method.
public static void ListToTreeview(TreeView treeview, List ListOfRows)
{
TreeNode root = new TreeNode(ListOfRows[0]);
TreeNode node;
treeview.Nodes.Add(root);
foreach(string s in ListOfRows)
{
node = root;
foreach (string level in samenvoegveld.Split('.'))
{
node = AddNode(node, level);
}
}
}