def leader_index(box):
    """Get the index of the first leader box in ``box``."""
    for i, child in enumerate(box.children):
        if child.is_leader:
            return (i, None), child
        if isinstance(child, boxes.ParentBox):
            child_leader_index, child_leader = leader_index(child)
            if child_leader_index is not None:
                return (i, child_leader_index), child_leader
    return None, None
Get the index of the first leader box in ``box``.
weasyprint/layout/leader.py