Handle nested empty array case by checking length

Just a quick bounds check before entering an empty array (currently it assumes at least one element). :)
Merge pull request #1 from cab/patch-1

Handle nested empty array case by checking length