def METHOD_NAME(stack: Stack):
    # If we've already established it as an obsolete stack to delete, we're good.
    if stack in plan.command_stacks:
        return
    # This check shouldn't be necessary, but we're just double-checking that it is indeed
    # not obsolete.
    if stack.obsolete:
        return
    # Theoretically, we've already gathered up ALL obsolete stacks as command stacks. If
    # we've hit this line, there's a problem. Now we just need to know what caused it. This
    # block climbs down the dependency graph to see which obsolete stack caused this stack
    # to be included in the plan.
    for dependency in stack.dependencies:
        if dependency.obsolete:
            raise CannotPruneStackError(
                f"Cannot prune obsolete stack {dependency.name} because stack {stack.name} "
                f"depends on it but is not obsolete."
            )
    # If we get to this point, it means this stack isn't obsolete and none of its dependencies
    # are either. That only happens it depends on another non-obsolete stack that depends on
    # an obsolete stack. As a result, we're not going to blow up here and instead will
    # continue iterating on the plan and will raise the error on a stack that directly
    # depends on the obsolete stack.
    return