how to fetch result into array or how to fetch 'nid' out of result? Good day to everyone!

some help needed with fetching result out of EntityFieldQuery. 
Have a unique value of the field. I try to get 'nid' of node by value of the field with help of EntityFieldQuery. my problem is that i dont know how to fetch result in a right way to get just 'nid'. then knowing nid i will be able to load the node and do some work with it.

$query = new EntityFieldQuery;
$entities = $query-&gt;entityCondition('entity_type', 'node')
-&gt;entityCondition('bundle', 'order')
-&gt;fieldCondition('field_reference_number', 'value', $titleref)
-&gt;execute();
$result= $query-&gt;execute();
drupal_set_message('nid: ' .print_r($result, true));


my result is:

nid: Array ( [node] =&gt; Array ( [2250] =&gt; stdClass Object ( [nid] =&gt; 2250 [vid] =&gt; 2252 [type] =&gt; order ) ) ) 


how to fetch it corectly to get 'nid' out of it?

Thanks for your time
The simplest way would be:

$result = $query-&gt;execute();

if (!empty($results['node'])) {
  $nids = array_keys($results['node']);
}


There are a few different ways to get the first nid out of the array if that's what you need; personally I prefer reset() as it's non-destructive to the original array (unlike array_shift() for example).

$first_nid = reset($nids);


If you then need the node objects you can pass that array straight to node_load_multiple():

$nodes = node_load_multiple($nids);