An American Airlines flight nearly crashed into a mountain range in Hawaii but avoided disaster by quickly gaining altitude.