Investigating astrophysical nitrogen-heterocycle formation with rotational spectroscopy and computational chemistry