The company obviously can't raise capital to buy itself by issuing shares, so it would have to get the money loaned to it. At this point I think it needs to convince its creditor that its stock is undervalued, and at that point the creditor is better off just buying the undervalued shares themselves. If they bought enough then they could take the company private if they wanted.
Now, maybe if someone who owned a company outright decided to donate all of their shares to the company, then it could "own itself". I don't know how that might work legally, though.