def METHOD_NAME(self, path=None):
    if not self.selection:
        return
    if not self.return_folders and self.selection[0].is_dir():
        self.path = self.selection[0]
        return
    if hasattr(self, 'on_submit'):
        self.on_submit(self.selection)
    self.close()