def keypress(self, size, key):
        if self.is_leaf:
            return key
        
        if key in ("+", "right"):
            self.expanded = True
            self.update_expanded_icon()
        elif key == "-":
            self.expanded = False
            self.update_expanded_icon()
        elif self._w.selectable():
            return self.__super.keypress(size, key)
        else:
            return key
Handle expand & collapse requests (non-leaf nodes)
dataset/ETHPy150Open AnyMesh/anyMesh-Python/example/urwid/treetools.py/TreeWidget.keypress