Maaser Sheni, Chapter 3, Mishnah 7. The Mishnah deals with a tree standing on the walls of Jerusalem: "Ilan she'omed lifnim v'noteh la'chutz, o omed ba'chutz v'noteh lifnim" - a tree planted inside the walls of Jerusalem whose branches lean out beyond the wall, or a tree planted outside the wall whose branches hang over and extend into Jerusalem.
The question is what the status of the various parts of the tree is: are they considered Jerusalem or outside? This question has two halachic ramifications: eating Maaser Sheni, which is permitted only in Jerusalem, and redeeming Maaser Sheni, which is not done inside the walls of Jerusalem unless it became tamei.
"Mikeneged hachomah ulifnim k'lifnim":
The halachah is determined by the position of the wall: "Mikeneged hachomah ulifnim k'lifnim, mikeneged hachomah ul'chutz k'lachutz".
Whatever is opposite the wall and inward - its status is that of Jerusalem: Maaser Sheni may be eaten there and may not be redeemed there.
Whatever is opposite the wall and outward - its status is that of outside: Maaser Sheni may not be eaten there, but it may be redeemed there.
Therefore, if the branches lean out beyond the wall, they are treated as outside, and Maaser Sheni may not be eaten beneath them, but it may be redeemed there.
The contradiction from the Mishnah in Maasros:
In Maasros we learned: "Uvirushalayim hakol holech achar hanof" - that in Jerusalem everything is determined by the position of the branches. This seemingly contradicts our Mishnah, according to which the matter depends on the position of the wall.
Some explain, based on the Gemara in Makkos, that the intent is "also by the branches" - that is, sometimes we follow the main part, the trunk, and sometimes the branches, and this depends on the position of the wall. For example, a tree planted outside Jerusalem whose branches are inside the city: in this case we follow the branches, because the branches are located inside the wall of Jerusalem. According to this explanation the matter fits with our Mishnah, that everything depends on the position of the wall, only that sometimes the position of the wall is what causes the law to be determined by the branches. There is another way to explain this, but we will suffice with this for now.
The status of the olive presses:
Olive presses were usually built inside the walls of the city, and so it was in Jerusalem as well. The Mishnah says: "Batei habadim shepischeihen lifnim vachalalan la'chutz, o shepischeihen la'chutz vachalalan lifnim" - the entrance of the olive press opens into Jerusalem, but the body of the building and its interior space are outside the wall; or the reverse, that the entrance opens to the outside of the wall while its interior space is inside Jerusalem.
Beis Shammai say: "Hakol k'lifnim" - the entire olive press is considered Jerusalem, and therefore Maaser Sheni may be eaten there and may not be redeemed there. This is how the Rav explains it. However, from the Tosefta it is proven that Beis Shammai's intent in saying "k'lifnim" is only as a stringency: Maaser Sheni may not be redeemed there, and nevertheless Maaser Sheni may not be eaten there either.
Beis Hillel say: "Mikeneged hachomah ulifnim k'lifnim, mikeneged hachomah ul'chutz k'lachutz" - no weight is given to the location of the entrance nor to the location of the interior space; rather everything is determined by the position of the wall: whatever is opposite the wall and inward is treated as Jerusalem, and whatever is beyond it is treated as outside, and the olive press is divided in two accordingly, based on its position relative to the wall of Jerusalem.
In summary: In this Mishnah we learned the rule of "mikeneged hachomah ulifnim k'lifnim, mikeneged hachomah ul'chutz k'lachutz" regarding a tree standing inside and leaning outward or the reverse, with respect to eating Maaser Sheni and redeeming it; we addressed the resolution of the contradiction from the Mishnah in Maasros, "uvirushalayim hakol holech achar hanof" - meaning "also by the branches"; and we learned the dispute between Beis Shammai and Beis Hillel regarding olive presses whose entrances are on one side and whose interior space is on the other, between those who treat the whole of it as inside and those who judge each part according to its position relative to the wall.