A Non-Sequential Dynamic Programming Approach for Natural Gas Network Optimization