'Give input focus to the next (or previous) item after *item*'

def focusNext(self, item, forward=True):

    while True:
        parent = item.parent()
        if (parent is None):
            return
        nextItem = self.nextFocusableChild(parent, item, forward=forward)
        if (nextItem is not None):
            nextItem.setFocus()
            self.setCurrentItem(nextItem)
            return
        item = parent
