def filter_constraints(
    node: cl.Node,
    filter_dom: r.Domain,
    var_assignments: dict[str, r.Domain] = None,
    check_correctness=True,
) -> tuple[cl.Node, bool]:
    """Return a constraint graph representing the component of `node` that is relevant for
    to a particular greedy filter domain.

    Parameters
    ----------
    node : cl.Node
        The constraint program to partition
    filter_dom : Domain
        The domain which determines whether a constraint is relevant
    var_assignments : Domain
        Domains to substitute for any t.Variable(name: str) in the constraint program, typically used for recursive calls.

    Returns
    -------
    partitioned: cl.Node
        The partitioned constraint program
    relevant: bool
        Was any part of the constraint program relevant?

    """

    assert isinstance(node, cl.Node), node

    if var_assignments is None:
        var_assignments = {}

    recurse = partial(
        filter_constraints, filter_dom=filter_dom, var_assignments=var_assignments
    )

    logger.debug(
        f"{filter_constraints.__name__} for {node.__class__.__name__}, {var_assignments.keys()=}"
    )
    new_node, relevant = _filter_node_cases(node, recurse, filter_dom, var_assignments)

    if relevant and check_correctness and isinstance(new_node, cl.ObjectSetExpression):
        _check_partition_correctness(new_node, filter_dom, var_assignments)

    logger.debug(
        f"Partitioned {node.__class__.__name__} to {new_node.__class__.__name__}"
    )

    return new_node, relevant
Return a constraint graph representing the component of `node` that is relevant for
    to a particular greedy filter domain.

    Parameters
    ----------
    node : cl.Node
        The constraint program to partition
    filter_dom : Domain
        The domain which determines whether a constraint is relevant
    var_assignments : Domain
        Domains to substitute for any t.Variable(name: str) in the constraint program, typically used for recursive calls.

    Returns
    -------
    partitioned: cl.Node
        The partitioned constraint program
    relevant: bool
        Was any part of the constraint program relevant?

    
infinigen/core/constraints/example_solver/greedy/constraint_partition.py