Flexible Mediation Analysis in the Presence of Nonlinear Relations: Beyond the Mediation Formula