EntityFieldQuery condition
You can simply do this:

$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'node');
// all other conditions go here

if (isset($my_field_val)) {
  $query-&gt;fieldCondition('my_field', 'value', $my_field_val);
}
$result = $query-&gt;execute();


Untried code as I don't have access to my files at the moment.