How to programmatically access the Block Styles for a stack V5.6.3.3

Permalink
I am building a mobile version of our theme and wish to automatically suppress certain blocks and stacks in the mobile version. For blocks I am doing this by adding a class 'no_mobile' to the block style. I can test this in the view with the following code:

$a = new Area('Sidebar');
    $page = Page::getCurrentPage();
    $blocks = $page->getBlocks('Sidebar');
    foreach ($blocks as $b){
        $csr = $b->getBlockCustomStyleRule();
        $cls = '';
        if (is_object($csr)){
           $cls = $csr->getCustomStyleRuleClassName();
        }
        if (strpos($cls, 'no_mobile') === FALSE){
            $b->display();            
        }
    }


The problem I have is that for stacks I want to set the 'no_mobile' class in the first block style in the stack rather than on every page that the stack is used.

When $b in the above is a stack how do I get the custom style for the stack? $b->getBlockCustomStyleRule() will return the style set on the page, not the stack custom style.

**********************************************************************************************************
In case anyone is interested I figured out a way to do this. I'm not sure if this is the most elegant but it works.
$a = new Area('Sidebar');
    $page = Page::getCurrentPage();
    $blocks = $page->getBlocks('Sidebar');
    foreach ($blocks as $b){
        // check if the 'block' is a stack
        if ($b->btHandle == 'core_stack_display'){
            $stack = Stack::getByID($b->getInstance()->stID);
            $stkBlocks = $stack->getBlocks();
            if (is_object($stkBlocks[0])){
                $csr = $stkBlocks[0]->getBlockCustomStyleRule();                
            }
        }
        else{
            $csr = $b->getBlockCustomStyleRule();
        }

BlowBubbles