def _find_existing_instance(self, predecessor):
    candidates = list(self.flow.activity_model.objects.filter(process=self.process, activity_name=self.name))
    for candidate in candidates:
        if (not candidate.successors.filter(status=candidate.STATUS_DONE, activity_name=self.name).exists()):
            return candidate
    raise self.flow.activity_model.DoesNotExist()
def _find_existing_instance(self, predecessor):
    candidates = list(self.flow.activity_model.objects.filter(process=self.process, activity_name=self.name))
    for candidate in candidates:
        if (not candidate.successors.filter(status=candidate.STATUS_DONE, activity_name=self.name).exists()):
            return candidate
    raise self.flow.activity_model.DoesNotExist()