Crossed products by endomorphisms and reduction of relations in relative Cuntz–Pimsner algebras