def _next_rdelim(items, pos):
    """Return position of next matching closing delimiter."""
    for num, item in enumerate(items):
        if item > pos:
            break
    else:
        raise RuntimeError("Mismatched delimiters")
    del items[num]
    return item