def for_all_model_rows(model, callback) -> None:
    """Iterate over all rows in the model."""
    stack = [QModelIndex()]
    while stack:
        parent = stack.pop()
        callback(parent)

        for row in range(model.rowCount(parent)):
            index = model.index(row, 0, parent)
            if not index.isValid():
                continue
            stack.append(index)
Iterate over all rows in the model.
angrmanagement/ui/widgets/qproperty_editor.py