public static void AddMomentumRecursively(this Layer layer) { layer.AddMomentum(); foreach (var previousLayer in layer.PreviousLayers) { previousLayer.AddMomentumRecursively(); } }