Optimal stomatal behavior with competition for water and risk of hydraulic impairment