def METHOD_NAME(self, item=None):
    """Change to the selected document and hide this widget."""
    if item is None:
        item = self.currentItem()
    # stack history is in inverse order
    try:
        index = self.stack_history[-(self.currentRow()+1)]
    except IndexError:
        pass
    else:
        self.editor.set_stack_index(index)
        self.editor.current_changed(index)
    self.hide()