how can I navigate in grouplist by code?

Hi.
When user directly touch grouplist items and list change it’s hierarchy - can i repeat this in code? Or, in other words, how can i program back button, so it would step out in parent list?

right now I’m using very hacky solution (for list nested no more than 3 - enough for my case):
var listelem1 = $$(‘list’).item($$(‘list’).idByIndex(0));
var listelem2 = $$(‘list’).item($$(‘list’).idByIndex(1));
var listelem3 = $$(‘list’).item($$(‘list’).idByIndex(2));
var getbackto = -1;
//my list.json has parent_id field, which has id of a parent element
if (listelem1[’$template’] == ‘Back’) {
getbackto = listelem1[‘parent_id’];
}
if (listelem2[’$template’] == ‘Back’) {
getbackto = listelem2[‘parent_id’];
}
if (listelem3[’$template’] == ‘Back’) {
getbackto = listelem3[‘parent_id’];
}
// in list.json root elements has parent_id = ‘root’
if (getbackto == “root”) {
$$(“top_list”).clearAll();
$$(“top_list”).load(“list.json”);
} else if (getbackto != -1) {
$$(‘top_list’).showItem(getbackto);
} else if (getbackto == -1) {
console.log(“exit!”);
navigator.app.exitApp();
}
this hack has two main flaws - showItem method doesn’t has animation, so user can be confused by differences in UI, and second - I have to reload list if user want to exit to root and my list have not one root elements but many (because showItem isn’t working in that case).

So, is there more sane solutions?

P.S. ‘list’ and ‘top_list’ in the code are the same - I just forgot to change it to one ‘list’

The next code is also not very clean, but maybe a bit simple approach

var list = $$('list'); list.on_click.dhx_list_item.call(list, {}, id);

where
list - id of list
id - id of item which need to be clicked

It will execute the same code as for normal touch|click action

It works perfectly - thanks!