Comparative many-body study of Pr4Ni3O8 and NdNiO2