New insights into the evolutionary history of biological nitrogen fixation