p_nodes won't be defined here if something causes that big try block to bail out before line 433. Is it even necessary to check here, however, given that such a failure would leave reason as None?