Accessing the active custom node tree in a script
Although there could be any type of nodetrees in bpy.data.node_groups, their names are unique and used as Identifiers.

So bpy.data.node_groups['Name of the Nodetree'] means exactly the nodetree with that name, no matter what type it has.

About the active node_tree you need to use the Node Editor's context, either by checking if the active node or the active node_tree is a node_group.

For example, if you have a custom node in a node_tree, and you want to access the node_tree itself from that node, you can look in the context:

node_tree = bpy.context.space_data.edit_tree

This will return the current tree being edited in the editor.