I've wrote this small script when the number of branches in my repo exceeded several hundreds. I did not know about the other methods (with CLI) so I decided to automate it with selenium. It simply opens Bitbucket website, goes to Branches, scrolls down the page to the end and clicks on every branch options menu -> clicks Delete button -> clicks Yes. It can be tuned to keep the last N (100 - default) branches and skip branches with specific names (master, develop - default, could be more). If this fits for you, you can try that way.
https://github.com/globad/remove-old-branches
All you need is to clone the repository, download the proper version of Chrome-webdriver, input few constants like URL to your repository and run the script.
The code is simple enough to understand. If you have any questions, write comments / create an Issue.