Finding menu item ID How to find a menu item pointing to the specific node?

On node creation I want to create a main_menu link for the node.
With menu_rules it is relatively easy. The problem arises when the parent element can differ.

main_menu
Groups
-[GROUPS]
--[GROUP_CONTENT]

main_menu
...
Groups
-A
--a1
--a2
-B
--b1
-C
...


In the above case adding a new group D is easy - I simply add a menu item to 'Groups', but what if I would like to add a3? 
I know the name of A and I know what it is linking to (a node representing a group) but I don't know its randomly generated menu ID (for example [menu-1082]). 

How do I find that Id?
I'm almost new user of Drupal, but I encountered the same problem because I write myself my modules.
My need is to create a node and to insert it as submenu of a main menu Item. I solved my problem in this way:

I wrote this function

function mymodule_get_plid($menu_name , $name) {
    $menu = menu_tree_all_data($menu_name);
    foreach ($menu as $item =&gt; $menuitem) {
        if ($name == $menuitem['link']['link_title']) {
            return $menuitem['link']['mlid'];
            break;  
        }
    }
    return false;
}


where $menuname is a string like 'main-menu', $name is the menu item for which I'm searching for it's Id. Function return Id if it find $name, false otherwise.

Now to complete node creation i wrote this.

$node = new stdClass();
$node-&gt;title = "YOUR TITLE";
$node-&gt;type = "page";  // Creating a node of Basic page type
node_object_prepare($node); // Sets some defaults. Invokes hook_prepare() and hook_node_prepare().
$node-&gt;language = LANGUAGE_NONE; // Or e.g. 'en' if locale is enabled
$node-&gt;uid = $account-&gt;uid;
$node-&gt;status = 1; //(1 or 0): published or not
$node-&gt;promote = 0; //(1 or 0): promoted to front page
$node-&gt;comment = 0; // 0 = comments disabled, 1 = read only, 2 = read/write

$node-&gt;menu['enabled'] = TRUE;
$node-&gt;menu['menu_name'] = 'main-menu';
$node-&gt;menu['plid'] = mymodule_get_plid('main-menu' , 'Inquiries');
$node-&gt;menu['link_title'] = 'MY SUBMENU NAME';
$node-&gt;menu['description'] = ''; // Needed even if empty to avoid notices.  /*  

$node = node_submit($node); // Prepare node for saving
node_save($node);


Now all behaves well, "MY SUBMENU NAME" is created as a new node and appended as sub menuitem of the 'Inquiries' menu Item of the main menu.