General solution of the Kozai mechanism