(2) A court that convicts a person of an offence under this section must not sentence the person to imprisonment unless the person has previously been convicted of an offence under this section or section 4 (or under the corresponding provisions of the Summary Offences Act 1988 as in force before their repeal by this Act) on so many occasions that the court is satisfied that the person is a serious and persistent offender and is likely to commit such an offence again.