Accessing the active custom node tree in a script I'd like to access the active custom custom node tree in the Python code.
It can be done through

    bpy.data.node_groups["name of the custom node tree"]


However there could be many node trees of the same type, so the name of the currently open node tree is unknown.
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.