A mountain pass theorem for a suitable class of functions