TreeTable Disallowing Children From Leaves

I’m trying to disallow children from leaves using the following method:

private void disallowChildrenFromLeaves(TreeTable ttable) {
for (Object itemId : ttable.getItemIds()) {
if (!ttable.hasChildren(itemId)) {
ttable.setChildrenAllowed(itemId, false);
}
}
}

With no success…
The reason MAY rest in the getItemIds not returning childrens id below the second level in the tree hierarchy.

Is this a bug? Am I doing something wrong?

My solution for now:

private void disallowChildrenFromLeaves(TreeTable ttable) {
for (Object itemId : ttable.getItemIds()) {
if (!ttable.hasChildren(itemId)) {
ttable.setChildrenAllowed(itemId, false);
} else {
disallowChildrenFromLeaves(itemId);
}
}
}

private void disallowChildrenFromLeaves(Object itemId) {
for (Object childId : ttable.getChildren(itemId)) {
if (!ttable.hasChildren(childId)) {
ttable.setChildrenAllowed(childId, false);
} else {
disallowChildrenFromLeaves(childId);
}
}
}

If there’s a better way to do this… please help.