You're close. Instead of AddLayer, you can use MoveLayer. The ESRI example code, along with some tweaks to your own data structures can be tweaked to move layers you want up to the root of the data frame. See code:
mxd = arcpy.mapping.MapDocument(r"C:\peendata\MoveLayers.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
moveThese = []
for layer in arcpy.mapping.ListLayers(mxd, "", df):
print str(layer.name) + ">>>"
if layer.isServiceLayer:
print str(layer) + " is a service layer"
if layer.isFeatureLayer:
print str(layer) + " is a feature layer"
if layer.isRasterLayer:
print str(layer) + " is a raster layer"
if layer.isGroupLayer:
print str(layer) + " is a group layer"
if str(layer) == "Group Layer 1":
refLayer = layer
if(layer.isServiceLayer and not layer.isGroupLayer):
print "qualifies for movement"
moveThese.append(layer)
for layer in moveThese:
print "moving " + str(layer)
arcpy.mapping.MoveLayer(df, refLayer, layer, "BEFORE")
mxd.saveACopy(r"C:\peendata\MoveLayersDone.mxd")
del mxd
Some caveats: not all web services are defined as web services. For example, OpenStreetMap, which you also add as an external link, is a layer package, so the code above will not move it. I did not find a way to detect whether it is a layer package from the web, so make sure the layers you want to move are what you expect code-wise.
In regards to your particular layer structure, be advised that Global_Imagery is a locked layer set, so you cannot its separate sublayers even in ArcMap by hand. In fact, the code still does it (kind of), but the moved layers are broken, and the original ones are still in place. Make sure the layers you are trying to move are actually moveable by hand.
Finally, the code should obviously be tweaked to what exactly you're looking for: you might not want them at the very root level, your topmost group layer might be called otherwise, etc. Included are some functions that you can use to test the layer's properties.
Oh and yes. Sometimes service layers are also group layers - so test carefully.
For reference, my layer structure pre and post:
