fix boolean casts after array cast

Once you cast a root element to an array, PHP will consider top level
child nodes as new 'root nodes', these nodes behave differently to child
nodes when it comes to boolean casting.