Espalier is the horticultural technique of training trees through pruning and grafting in order to create formal "two-dimensional" or single plane patterns by the branches of the tree. The technique was popular in the Middle Ages in Europe to produce fruit inside the walls of a typical castle courtyard without interfering with the open space, and to decorate solid walls by such trees planted near them. Evidence exists suggesting that the technique dates back much further, perhaps even to ancient Egypt. The word espalier initially referred to the actual trellis on which the plant was trained to grow, but over time has come to be used to describe the technique.
An espalier collects almost as much sunlight as a regular tree, yet has far less mass. This makes them ideal not only for decorative purposes, but also for gardens in which space is limited. They may also be planted next to a wall, which can reflect more sunlight and retain heat overnight, or be planted so that they are facing south (or north, if planting south of the equator) and absorb maximum sunlight. These two facts allow an espalier to succeed in cooler climates, where a non-espaliered tree of the same variety would fail. They also mature fruit more quickly. Certain types of trees adapt better to this technique than others, although any fruit tree will theoretically work. The branches of the plant must be long and flexible. Examples of trees that take well to espalier are figs, apples and pears. Peaches, plums, apricots and cherries can also be grown flat against a wall, but are generally happier in less structured forms than those used for apples and pears.