def find_last()

in bowler/helpers.py [0:0]


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