I'm sure I'm just overlooking something, but I can't see what it is.
I have a page I'm using to test some new code with using the console. Most of it works.
    if(typeof(thisNode.L1.download) != 'undefined') {
    console.log('a1');
        if (thisNode.L1.download.sku.toString() == lastSku) {
            console.log('a2');
            addSku = thisNode.L1.cd.sku.toString();
        } else { console.log('a3'); }
    } else if(typeof(thisNode.S5.download) != 'undefined') {
        console.log('b1');
        if (thisNode.S5.download.sku.toString() == lastSku) {
            console.log('b2');
            addSku = thisNode.S5.cd.sku.toString();
        } else {
            console.log('b3');
        }
    }
    console.log('foo');
returns
    a1
    a3
    foo
    undefined
given that typeof(thisNode.S5.download) != 'undefined' returns true
and lastSku returns "24536" 
and thisNode.S5.download.sku.toString() returns "24536"
This is not expected.
I did some breaking down and it looks like it's the initial if statement that is the problem.
I enter into the console: if (thisNode.L1.download.sku.toString() == lastSku) {} i get "undefined"
So I checked it piece by piece
lastSku returns "24536"
thisNode returns a JSON object. Object {L1: Object, S2: Object, S3: Object, S5: Object}
thisNode.L1 returns Object {box: Object, download: Object, cd: Object}
thisNode.L1.download returns Object {sku: 24354}
thisNode.L1.download.sku returns 24354
thisNode.L1.download.sku.toString() returns "24354"
thisNode.L1.download.sku.toString() == lastSku returns false
    if (thisNode.L1.download.sku.toString() == lastSku) {
        console.log('foo');
    } else {
        console.log('bar');
    }
returns "bar" undefined
    if (thisNode.L1.download.sku.toString() == lastSku) {
       console.log('foo');
    } else {
        console.log('bar');
    }
    console.log('yabba');
returns
    bar
    yabba
    undefined
Note that I can put any JavaScript in the original if statement and i still get undefined, so it's not that there's no code for it to skip.
To recap, the original block doesn't appear to ever get to line 7 but it does look like after running through the first set of if statements it does keep running code after all of them.
