Structure theorems for linear and non-linear differential operators admitting invariant polynomial subspaces