First off, to get the currently active node, you can use
currNode = context.active_node
from within an addon / Operator (which I suppose you're doing, otherwise there would be no bpy.context.selected_nodes). From the Python Console, getting the currently active node in the compositing tree would be
currNode = bpy.context.scene.node_tree.nodes.active
From there, you can use
currNode.id_data
to retrieve the tree this node lives in. This also works in Material Node Trees. To retrieve the materials (remember it could theoretical be more than one material using the same node tree) you can to:
print ([x for x in D.materials if x.node_tree == currNode.id_data])
So in your example:
# get a node first
x = D.node_groups['NodeGroup'].nodes['Group Input']
# now get the tree of this node (which is the node group)
x.id_data # this gives you 'Node Group' again
Edit: Find the node tree of a group
After the question has been rephrased, this solution would be smarter: Node groups simply have an own Node Tree themselves. You can think of it like:
ShaderNodeTree.nodes[someGroup].node_tree.nodes[someOtherGroup].node_tree.nodes.thisCanGoOnForever
So in your case:
active_node = context.active_node
# active_node.name: Group.003
# active_node.group: Test 1
# find an image node in the group node tree
# groups have their own node tree to collect nodes
img_node = active_node.node_tree.nodes.get("Image Texture 1")
If the Image Texture named "Image Texture 1" exists, img_node will be the object. Otherwise, img_node will be None.
context.active_nodereturns an object of typeShaderGroupNode! I only read the documentation ofShaderNodeinstead... – Steffen Dec 02 '16 at 12:13