Prevent traversing second level nodes in container-less foreach body. This could have caused nodes to appear in wrong sequence.
Added support for using 'as' to give an alias to foreach items.