If one declares a bankruptcy, can he or she keep his/her mortgage account and continue repaying it, while erasing all the other debts? In general, is it possible to negotiate to keep some credit accounts open, but wipe off all other debts?
You’ve not said what jurisdiction you’re interested in, so here’s a UK answer. An Individual Voluntary Arrangement lets you do exactly what you’re asking for. The catch is that as the name suggests, it must be agreed by your creditors — it can’t be imposed on them like bankruptcy can. You need 75% (by exposed value) of them to vote for it (and 50% of those who aren’t your business associates, friends and family).
For mortgage debt specifically, it will depend on the jurisdiction and exactly what sort of bankruptcy you're declaring. In the United States, most if not all states have some sort of homestead exemption that allows a person to retain a primary home in bankruptcy (often with limits to prevent people from keeping homes where they have millions in equity). Assuming you're talking about a primary home and your equity is sufficiently low, you'd generally be able to keep the asset and continue repaying the loan once you emerged from bankruptcy.
For other debts, it will depend on the debt. Again, most states in the US have provisions to allow people to retain a car (assuming you have sufficiently little equity in the car). If you are filing for Chapter 13 bankruptcy (restructuring), you would likely also be able to keep open credit accounts for things like tools you use for work. Generally, though, bankruptcy should treat similarly situated creditors similarly so you generally can't negotiate to, say, pay back your brother-in-law in full when other unsecured lenders get 80 cents on the dollar.