def METHOD_NAME(self, span):
    # type: (Span) -> Optional[Span]
    """Updates the active span in an executor.
    The active span is updated to be the span's parent if the span has
    finished until an unfinished span is found.
    """
    if span.finished:
        new_active = span  # type: Optional[Span]
        while new_active and new_active.finished:
            new_active = new_active._parent
        self.activate(new_active)
        return new_active
    return span