I'm guessing the Arduino environment doesn't like nested functions.
It does not. You can have multiple function CALLS though, nested as deep as you like.
The IDE combines all of your sketches to produce one cpp file that it passes to the compiler.
The order of the sketches matches the order of the tabs, NOT any logical order. The tab order depends on the name of the file in the tab, so you can impose order by naming the tabs so that they are sewn together in the proper "order".
Or, define your own function prototypes, in the main sketch tab, and then the order won't matter.