Well can you post the PHP? You are still parsing extra loops because of the blank nodes.
It can separate it out I'm sure, but I can't test anything since I don't have flash on this computer right now. Try this,
right after you set MY_PIC in the loop. It should output the value, and see if the blank nodes are given a value which you can use to check against.