import itertools


def resolve_list(name: str, env) -> str:
    """Finds the list with specified name in env."""
    for lst in itertools.chain(env["sprite"]["lists"], env["stage"]["lists"]):
        if lst["name"] == name:
            return lst["id"]
    raise NameError(f"List '{name}' does not exist")