Mr. Talabani then traveled to Tehran for the first visit to Iran by an Iraqi head of state in nearly four decades .