(Reuters) - Of all the problems facing Detroit, getting court recognition as a legally bankrupt entity was actually the easy part.

The next step, which starts this week, is where it gets tricky. With a bankruptcy declaration in hand, Detroit and its top-flight advisors now must pinpoint potential allies, isolate opponents and strike deals where needed, as they begin seeking a path that will get them out of the largest ever municipal bankruptcy with broad public support and hopes for a revitalized city.

Though the parties have been involved in court-ordered mediation for months, the process will begin in earnest Tuesday as U.S. Judge Steven Rhodes during three days of hearings seeks to determine if Detroit can end pricey interest-rate swap deals and secure a $350 million loan, known as debtor-in-possession financing.

A number of groups, including city bondholders and banks, have objected to ending the swaps deal and establishing the financing. However, on Monday the city saw some progress when bond insurer Assured Guaranty Municipal Corp withdrew its opposition. Detroit's retiree committee previously had done so.

If the city does win court approval for the deal, it will represent a key step for emergency manager Kevyn Orr. Earning support of at least one class of impaired creditors is one of the minimum requirements for bringing Detroit with its $18.5 billion in debt out of Chapter 9.

One bankruptcy lawyer called Orr's push for the swaps deal part of a "Rubik's Cube strategy" of aligning the pieces to secure approval for a plan, although this attorney noted that strategies common to commercial bankruptcies may not apply to Detroit.

"The playbook for a bankruptcy lawyer on the debtor side is to figure out how to get classes organized and to get to an impaired class, and particularly to get to a consenting impaired class, as quickly as possible because that changes the dynamic at the negotiating table," said Karol Denniston of Schiff Hardin in San Francisco.

UNLIKELY OPTION

Orr has made termination of the swaps deal one of his top priorities in order to secure access to the tax revenue from Detroit's casinos. As Orr said in October on the witness stand during Detroit's bankruptcy eligibility trial, that income is "probably the most stable source of revenue for the city."

About $230 million of Detroit's loan, provided by Barclays PLC, will be used to terminate the swaps deal, and Orr hopes to use the remainder to finance quality-of-life improvements, such as the removal of blight, throughout the city.

The city is ending the swaps deal by paying UBS and Bank of America's Merrill Lynch at a discounted rate of as much as 25 percent.

Should Orr win court approval for the swaps deal, he would meet one of the minimum legal requirements to request an exit from bankruptcy. If he did request approval at that point, he would be taking a page from the corporate bankruptcy playbook, in which the bankrupt party forces other classes of creditors to accept terms in a process known as a "cramdown."

FAIR AND EQUITABLE

The reality is that in a Chapter 9 bankruptcy like Detroit's Orr also must demonstrate his plan is fair and equitable, and Rhodes in ruling Detroit is bankrupt said he intends to hold the city to that standard.

"What does fair and equitable mean? It's very fuzzy in a Chapter 9 case," said Juliet Moringiello, a professor at Widener Law School in Harrisburg, Pennsylvania.

All sides have been engaged in mediation for months. And Orr at this point likely is working to line up classes of creditors to build a sense of momentum, hoping to place pressure on other creditors to join in a settlement

Orr obtained some help from Judge Rhodes' 150-page ruling earlier this month that declared Detroit eligible for bankruptcy protection. In it, Rhodes noted that the onus for good faith negotiation falls on all parties, not just the city.

Rhodes' ruling means Orr might choose a cramdown tactic if a holdout group of creditors emerges, so long as he believes he can establish the end result is not unfair, lawyers said.

Still, there is no precedent for a large city going through bankruptcy, and there are few examples of a municipality of any size coming out by way of a cram down.

The bankruptcy of the California city of Stockton appeared to be heading for a cramdown plan, but the city steadily has gained support from an ever-wider group of creditors as the case has drawn on.

Earlier this month Jefferson County, Alabama, home to Birmingham, came out of its bankruptcy with the vast majority of creditors on board.

Murky standards and thin case law could mean lengthy appeals that would only delay Detroit's recovery. And risks are high since even this week's swaps deal, which Orr considers critical to the city's future, is opposed by bondholders, unions, retirees and the city's two pension funds.

A consensual restructuring plan would be the best way to avoid litigation delays.

"We hope to reach a negotiated solution even now," Orr said from the witness stand during the eligibility trial.

One bankruptcy specialist said Detroit's revitalization depends on a broad agreement among residents, workers, retirees and financial creditors.

"You want to make sure they're all rowing in the same direction to help the city reinvest in itself and expand," said James Spiotto of Chapman and Cutler in Chicago. "That's the only way to grow the city and growing the city is the only way to recover."

(Reporting by Joseph Lichterman in Detroit and Tom Hals in Wilmington, Delaware; Editing by Lisa Shumaker)