I think the code is working correctly but the description is wrong. It should be halving impurity penalty, not impurity.
Edit:typo