Fold deeply nested functions for the high-level view