How to stop extremists from making a party unelectable