Generalization of the Beltrami identity to functionals with higher derivatives Suppose that I have a functional $S[q]=\int_a^b L(t,q(t),q'(t))\,dt$. Such a functional is well-known to extremized by a choice of $q(t)$ satisfying the Euler-Lagrange equation $\dfrac{d}{dt}\dfrac{\partial L}{\partial q'} = \dfrac{\partial L}{\partial q}$. If the integrand has moreover no explicit $t$-dependence, then one can show that the Beltrami identity holds: $L-q'\dfrac{\partial L}{\partial q'}=C$ for some constant $C$.
Now, it is also known how the Euler-Lagrange equation generalizes to functionals depending on higher derivatives ($q'',q'''$, etc.). Does the Beltrami identity also generalize?
 A: For a general Lagrangian $L[t,q,q',q'',\ldots]$ the Euler-Lagrange equation reads
$$L_q = [L_{q'}]' - [L_{q''}]'' + [L_{q''}]''' - \ldots = \sum_{n\geq 1} (-1)^{n+1}[L_{q^{(n)}}]^{(n)}$$
If the Lagrangian is time-independent. $L_t = 0$, we have
$$\frac{dL}{dt} = L_qq' + L_{q'}q'' + L_{q''}q''' + \ldots = L_q q' + \sum_{n\geq 1}L_{q^{(n)}}q^{(n+1)}$$
and by combinding the equations above we arrive at
$$-L' + \color{blue}{L_{q'}q'' + [L_{q'}]'q'} + \color{red}{L_{q''}q''' - [L_{q''}]''q'}  + \color{blue}{L_{q'''}q'''' + [L_{q'''}]'''q'} + \ldots  = 0$$
which can be written
$$-L' + \sum_{n\geq 1} L_{q^{(n)}}q^{(n+1)} + (-1)^{n}[L_{q^{(n)}}]^{(n)}q' = 0$$
Note that
$$(-1)^{n+1}\frac{d}{dt}\left[q'[L_{q^{(n)}}]^{(n-1)} - q''[L_{q^{(n)}}]^{(n-2)} + q'''[L_{q^{(n)}}]^{(n-3)} + \ldots + (-1)^{n+1}q^{(n)}L_{q^{(n)}}\right] \\= q^{(n+1)}L_{q^{(n)}} + (-1)^{n+1}q'[L_{q^{(n)}}]^{(n)}$$
which after integrating up gives us the identity
$$L + \sum_{n\geq 1}\sum_{k=1}^n (-1)^{k+n+1}q^{(k)}[L_{q^{(n)}}]^{(n-k)} = C$$
Writing out the first few terms gives us
$$L \color{brown}{- q'L_{q'}} \color{red}{ + q'[L_{q''}]' - q''L_{q''}} \color{blue}{- q'[L_{q'''}]'' + q''[L_{q'''}]' - q'''L_{q'''}} + \ldots = C$$
The presence of the time-derivatives of the partial derivatives for $n\geq 2$ makes it less useful of an identity than what the Beltrami identity is.

As a check applying this to the question you linked where $L[y,y''] = y + \frac{y^2}{2} - \frac{(y'')^2}{2}$ whose Euler-Lagrange equation is $1 + y - y^{(4)} = 0$ we arrive at
$$\frac{1}{2} y''^2-y^{(3)} y'+\frac{y^2}{2}+y = C$$
Taking the derivative we get
$$y'(1+y-y^{(4)}) = 0$$
which is true by the Euler-Lagrange equation.
