Use if exists in postgresql
select l.* 
from location as l                             --- find all locations
where not exists                               --- where there isn't 
      ( select * 
        from location_flag as lf               --- a flag
        where lf.location_id = l.id 
          and lf.flag_id = 1                   --- with 1
          and lf.value = 'YES'                 --- and YES
          and not exists                       --- without 
              ( select *                      
                from location_flag as lf2      --- another flag
                where lf2.location_id = l.id 
                  and lf2.flag_id = 2          --- with 2
                  and lf2.value = 'YES'        --- and YES
              )
      ) ;


or:

select l.* 
from location as l 
where not exists 
      ( select * 
        from location_flag as lf
        where lf.location_id = l.id 
          and lf.flag_id = 1 
          and lf.value = 'YES'
      )
   or exists
      ( select * 
        from location_flag as lf2
        where lf2.location_id = l.id 
        and lf2.flag_id = 2 
        and lf2.value = 'YES'
      ) ;