In 2017, the constituency of North East Fife underwent three recounts, eventually leading to the SNP candidate being elected with a majority of just two votes. The initial result would have seen the Liberal Democrat candidate achieve victory with a majority of three votes.
As the counts and subsequent recounts led to a split in results - with two counts giving victory to the Lib Dems, and two counts giving victory to the SNP - the Liberal Democrats indicated that they would launch a legal challenge. This was later dropped by the leader of the Scottish Lib Dems.
While this was the closest result in terms of votes in 2017, it was not the constituency with the most recounts - this was Richmond Park, which underwent 4 recounts before the Conservative candidate won with a majority of 45.
What is the procedure which allows for a recount to be conducted? What explains the fact that a fourth recount was denied in Fife but allowed in Richmond Park, despite the result being much closer in the former? Perhaps the rules differ between Scotland and England?