LetT be a unital algebra with nontrivial idempotents. For any s1, s2, . . . , sn ∈ T, define p1(s1) = s1, p2(s1, s2) = [s1, s2] and pn(s1, s2, . . . , sn) = [pn−1(s1, s2, . . . , sn−1), sn] for all integers n ≥ 3. In the present article, it is shown that if a map φ : T→ T satisfies φ(pn(s1, s2, . . . , sn)) = n∑ i=1 pn(s1, . . . , si−1, φ(si), si+1, . . . , sn) (n ≥ 3) for all s1, s2, . . . , sn ∈ T with s1s2 · · · sn = 0, then φ(s + t) − φ(s) − φ(t) ∈ Z(T) for all s, t ∈ T, and under some mild assumptions φ is of the form δ + τ, where δ : T → T is an additive derivation and τ : T → Z(T) is a map such that τ(pn(s1, s2, . . . , sn)) = 0 for all s1, s2, . . . , sn ∈ T with s1s2 · · · sn = 0. The above results are then applied to certain special classes of unital algebras, namely triangular algebras, full matrix algebras and algebra of all bounded linear operators.