Solutions to a generalized spheroidal wave equation: Teukolsky’s equations in general relativity, and the two‐center problem in molecular quantum mechanics