Generally in Drupal query builder, we can chain condition() method to add AND conditions to the query we are building.
Which will create a query something like 
WHERE Condition1 AND Condition2 AND Condition3	
by following code:
condition(Condition1)
  ->condition(Condition2)
  ->condition(Condition3); 

?>
 
Now If we want OR,
condition(
      db_or()
        ->condition(Condition1)
        ->condition(Condition2)
        ->condition(Condition3)
  );
  
?>
If we want to nest OR inside AND,
//something like 
WHERE (Condition1 OR Condition2) AND (Condition3 OR Condition4)	
You can do:
condition(
    db_or()
      ->condition(Condition1)
      ->condition(Condition2)
  );

$query
  ->condition(
    db_or()
      ->condition(Condition3)
      ->condition(Condition4)
  );
If we want to nest AND inside OR,
something like
WHERE (Condition1 AND Condition2) OR (Condition3 AND Condition4)
You can do:
condition(
      db_or()
        ->condition(
            db_and()
              ->condition(Condition1)
              ->condition(Condition2)
        )
        ->condition(
            db_and()
              ->condition(Condition3)
              ->condition(Condition4)
        )
  );