def METHOD_NAME(domain_name, workflow_id, run_id=None):
    domain = simpleflow.swf.mapper.models.Domain(domain_name)
    # if no run_id provided, we assume that the requester wanted the last
    # execution with that workflow_id
    found_run_id = None
    if not run_id:
        qs = simpleflow.swf.mapper.querysets.WorkflowExecutionQuerySet(domain)
        wfe = qs.filter(
            workflow_id=workflow_id, status=simpleflow.swf.mapper.models.WorkflowExecution.STATUS_OPEN
        ) or qs.filter(workflow_id=workflow_id, status=simpleflow.swf.mapper.models.WorkflowExecution.STATUS_CLOSED)
        if wfe:
            # by default, workflow executions are returned in descending start time order
            # so the first returned is the last that has run
            found_run_id = wfe[0].run_id
        else:
            # we would send a malformed request to SWF API, better stop directly
            raise ValueError(f"Couldn't find an execution with workflowId={workflow_id}")
    return simpleflow.swf.mapper.querysets.WorkflowExecutionQuerySet(domain).get(
        workflow_id=workflow_id,
        run_id=run_id or found_run_id,
    )