def find_first()

in bowler/helpers.py [0:0]


def find_first(node: LN, target: int, recursive: bool = False) -> Optional[LN]:
    queue: List[LN] = [node]
    queue.extend(node.children)
    while queue:
        child = queue.pop(0)
        if child.type == target:
            return child
        if recursive:
            queue = child.children + queue
    return None