How to use python to copy image poroperties from the compositor to the 3D viewport

I’m trying to write a script to copy image properties from the a node in the compositor to the background image of a 3D viewport.

By naming the image node and the background, I’ve managed to change the image in the 3D view e.g.

>>> bpy.data.images["background_b"].filepath = bpy.data.images["Moon.b1"].filepath

However, I’m stuck with the start frame and offset, which seem to be properties of ImageUser. The tooltip says

>>> bpy.data.screens["Animation.back"]..frame_start

which, as far as I understand, means I need to put something between [“Animation.back”] and .frame_start but what is it?

Can anyone tell me the proper syntax to reference:
a) the frame_start and frame_offset for the background in a 3D viewport, and
b) those same properties from an image node in the compositor?

Any pointers would be much appreciated.

UPDATE: I’ve worked out the node references - e.g.

>>> bpy.data.scenes['Ship.back'].node_tree.nodes["Moon.b1"].frame_offset

Now I just need the referenceS to the 3D viewport background.

OK!!! I worked out the rest thanks largely to this post: https://blenderartists.org/forum/showthread.php?385451-Adding-3D-view-background-with-Python

Here’s an example:

>>>bpy.data.screens["Animation.front"].areas[5].spaces[0].background_images[0].image_user.frame_start

Obviously, finding the “areas[5]” took a bit of trial and error, as my screen has 10 areas, five of which are 3d viewports.

I have to say I’m surprised that this hasn’t come up before - seems to me that duplicating a video background node in a 3D viewport would be a common need.