Distributed optimization of deeply nested systems