The Bank of Montreal won't have to pay potentially tens of millions of dollars in disputed taxes after a judge ruled a complicated shell-company structure it used to lend money to its own subsidiaries didn't run afoul of the law.