Expose layer outside loop in layer-check

This allows us to return the max layer value when the element is in the
top layer