An Ethical Trajectory Planning Algorithm for Autonomous Vehicles