def METHOD_NAME(spaces: typing.Iterable[typing.Union[dolfinx.fem.FunctionSpace, None]],
                 bcs: typing.Iterable[DirichletBC]) -> typing.List[typing.List[DirichletBC]]:
    """Arrange Dirichlet boundary conditions by the function space that
    they constrain.
    Given a sequence of function spaces ``spaces`` and a sequence of
    DirichletBC objects ``bcs``, return a list where the ith entry is
    the list of DirichletBC objects whose space is contained in
    ``space[i]``.
    """
    def _bc_space(V, bcs):
        "Return list of bcs that have the same space as V"
        return [bc for bc in bcs if V.contains(bc.function_space)]
    return [_bc_space(V, bcs) if V is not None else [] for V in spaces]