private boolean removeUnreachableIfBlocks(AST ast) 
    {
        return rewriteAST( ast , new ASTRewriter() {

            @Override
            protected boolean rewriteNode(ASTNode n, IIterationContext context)
            {
                if ( n instanceof IfNode ) 
                {
                    final IfNode ifNode = (IfNode) n;
                    if ( ifNode.getCondition() instanceof NumberLiteralNode ) 
                    {
                        final boolean isAlwaysTrue = ((NumberLiteralNode) ifNode.getCondition()).getValue() != 0;
                        System.out.println("Removing dead code ("+ ( isAlwaysTrue ? "always true" : "always false")+") from: "+ASTUtils.toString( ifNode ) );

                        final ASTNode removedBlock;
                        if ( isAlwaysTrue ) 
                        { 
                            // if ( ALWAYS TRUE ) => replace IF with BODY block
                            if ( ifNode.hasElseBlock() ) {
                                // else block was removed
                                removedBlock = ifNode.getElseBlock();
                            } else {
                                removedBlock = null; // if has no else block => nothing removed
                            }
                            if ( ! ifNode.getBody().hasChildren() ) { 
                                ifNode.removeFromParent();
                            } else {
                                ifNode.replaceWith( ifNode.getBody() );
                            }
                        } 
                        else 
                        {
                            // if ( ALWAYS FALSE ) => replace IF with ELSE block (if any)
                            if ( ifNode.hasElseBlock() ) 
                            {
                                // replace if () with else block
                                removedBlock = ifNode.getBody();
                                if ( ifNode.getElseBlock().hasChildren() ) {
                                    ifNode.replaceWith( ifNode.getElseBlock() );
                                } else {
                                    ifNode.removeFromParent(); // empty block, remove IF completely
                                }
                            } else {
                                // remove if completely , body is never executed
                                ifNode.getParent().removeChild( ifNode );
                                removedBlock = ifNode;
                            }
                        }

                        // update scope: remove any variables that were defined in this block
                        if ( removedBlock != null ) {
                            codeRemoved( removedBlock );
                        }
                        return true;
                    }
                }
                return false;
            }

            @Override
            protected void rewriteAST(ASTNode ast)
            {
                ASTUtils.visitDepthFirst( ast , this );                   
            }
        });        
    }