Sometimes we have a use for both old and new trees. Cleaner programming style. Pure functions can always be tested separately . They are the way in which programmers express procedural abstraction , i.e., how to perform a given sequence of steps on an arbitrary set of values. Top-level procedures are indispensable, but limited.
Many languages go further.
Functions can be passed as arguments to other functions. Functions can be returned as results of other functions or stored into data structures. Function values can be anonymous , i.e., a function can be denoted without declaring a name for it. Most conventional languages offer a subset of these capabilities. It can be useful to declare functions inside other functions.