def METHOD_NAME(self, judge):
    with self.lock:
        node = self.queue.first
        priority = 0
        while node:
            if isinstance(node.value, PriorityMarker):
                priority = node.value.priority + 1
            elif priority >= REJUDGE_PRIORITY and self.count_not_disabled() > 1 and sum(
                    not judge.working and not judge.is_disabled for judge in self.judges) <= 1:
                return
            else:
                id, problem, language, source, judge_id, banned_judges = node.value
                if judge.name not in banned_judges and judge.can_judge(problem, language, judge_id):
                    self.submission_map[id] = judge
                    try:
                        judge.submit(id, problem, language, source)
                    except Exception:
                        logger.exception('Failed to dispatch %d (%s, %s) to %s', id, problem, language, judge.name)
                        self.judges.remove(judge)
                        return
                    logger.info('Dispatched queued submission %d: %s', id, judge.name)
                    self.queue.remove(node)
                    del self.node_map[id]
                    break
            node = node.next