Fix #269: Managed Area layer legend items not appearing.

As a result of fixing #255, where we removed parent node ids from the
list of visible layer ids, the map legend for nested layers fails to
render on the map export.

This change will append all parentLayerIds from visible layers to the
PrintTask template when the map is exported.
I will simplify this more and add better documentation. This is supposed to be a breadth first node traversal that will continuously add parent nodes to the result by following the tree (of visible layers) all the way back to the root layer.

It was a huge oversight to not consider layerIds of 0 so I'll fix this too.