TransCanada is suing the U.S. government for blocking the construction of the Keystone XL pipeline. The company argued in their federal court filings that President Obama had overstepped his Constitutional powers in putting the brakes on the project.

The lawsuit is being brought under the North American Free Trade Agreement (NAFTA) and the company is seeking $15 billion in damages from the federal government.

This move by TransCanada was entirely predictable, because when it comes to the energy sector, NAFTA has a lot to say, and most of it isn’t good. At the heart of it, NAFTA mandates that member countries cannot discriminate against foreign energy companies. This means that a Canadian energy company is legally allowed the same opportunities as American companies operating in the U.S. Since we’ve allowed our oil companies to construct pipelines, it would be illegal, in most circumstances, to deny that same privilege to TransCanada.

Furthermore, NAFTA significantly weakens the host government’s ability to restrict a project, even if that project would violate the government’s own regulations and standards. For example, Exxon has been successful in bringing NAFTA challenges to drilling projects that the Canadian government had denied the oil giant.

The case will be heard under NAFTA’s Chapter 11 tribunal system, and the United States has never lost a Chapter 11 case in the past. However, other energy companies have been successful in filing Chapter 11 cases in other NAFTA member countries, including a recent case in Ottawa, Canada where Exxon Mobil and Murphy Oil were awarded a combined $17 million.

Compounding the problems for the United States is the fact that South Dakota recently renewed TransCanada’s Keystone XL permit that had expired in 2014, giving the company hope that they will be able to continue construction.

But all hope for the environment is not yet lost, as NAFTA also has a few built in mechanisms that could put the final nail in the Keystone XL coffin.

The glimmer of hope comes from a provision in NAFTA that created the Commission for Environmental Cooperation (CEC). The CEC is tasked with ensuring that environmental concerns are thoroughly examined when dealing with NAFTA. It lays out environmental issues as they would apply to the entire continent, not just the host government’s concerns. These broad terms could easily help make Keystone XL a distant memory, as the environmental consequences of a spill could span the continent. Specifically, a leak in the portion of the pipe that would still pass over the Ogallala aquifer could poison as much as 25% of America’s crops, which are exported throughout North America.

The problems with the latest moves from TransCanada all stem from bad trade agreements signed by the United States. And the ones already in place are nothing compared to the massive Trans Pacific Partnership (TPP) that President Obama is currently pushing.

According to Lori Wallach of Public Citizen’s Global Trade Watch, the TPP would allow multinational corporations to overstep federal environmental regulations in the name of business, thereby putting the interests of the company ahead of the laws of the governments involved in the agreement. This means that corporations will legally be allowed to ignore existing environmental protections if they interfere with their “business as usual.”

It all comes down to politics and money. TransCanada has enough cash on hand to handle not only a long legal battle, but also to help persuade the next President of the United States that the pipeline is a great idea. But make no mistake about it: The only people that will benefit from the construction of this pipeline will be the shareholders of TransCanada.