In Richard Borcherds' (excellent) lectures on Youtube, he mentioned on a couple occasions that when one wants to construct a prime ideal with a certain property, a good strategy is to look at the set of ideals with that property, and very often a maximal element of this set is prime. For example (beyond the obvious example that maximal ideals are prime), he used this to show that for any ideal $I$ of a commutative ring and multiplicative subset $S$ such that $S\cap I=\emptyset$, there is a prime ideal containing $I$ that does not meet $S$.
Can this be formalized? I.e., is there a condition on a subset of the set of ideals of a (commutative) ring that would ensure that a maximal element (if it exists) is prime?