Optimization And Flow-Invariance Via High Order Tangent Cones