If a company must select whom to layout it would seem logical to pick those who presently aren't contributing because they just had a kid and are on leave and yet we don't really want to live in a society where people are worried about having kids because they might be punished for it by being fired not least of which because we need a next generation and don't want the entirety of it to come from less intelligent people in lower performing households.
To take away the incentive and ensure at least the appearance of objectivity—different from emotional nonsensical fairness—its wise to decouple layoffs from maternity by dealing with any change in employment status after the end of maternity leave. If it still makes sense to lay them off or fire them after the end of their leave.