Rav Anan's land was flooded. The boundaries were washed away. He rebuilt the wall on his neighbor's property (accidentally). His neighbor later realized that Rav Anan had built the wall on his land so he asked Rav Anan to move the wall back to it's original spot. Rav Anan refused. They then went to R' Nachman. Rav Anan claimed that since the neighbor had helped him build the wall it showed that he was מוחל the land. R' Nachman answered, he made a mistake, he thought it was really yours.Was Rav Anan's behavior moral and worthy of praise? IMHO, the answer is no. Rav Anan did not dispute that the border was moved and therefore the right thing to do would be to simply give back the land. Rav Anan's attempts to use legal tricks to keep the stolen land were unworthy.
The Gemara then relates a similar story:
Also Rav Kahana's land was flooded. He rebuilt the wall on his neighbor's property. The case came before Rav Yehudah. One witness said that he took (the width of) two rows of his neighbor's property, and the other witness said that he took three rows. Rav Yehuda said that he must return 2 rows (because both witnesses agreed that he took at least 2 rows). R' Kahana answered that since the witnesses contradicted (one said 2 one said 3) each other he should keep all the land.
Again, R' Kahana knew that he had stolen some land, the moral thing to do would be to simply return it not try to find legal tricks to keep it.
Here are links to the previous posts on this topic:Were the Amoraim/Tannaim paragons of virtue? Part 3