Consider the following:
data={2,2,2,5,3,3,3,6,1,1,1,0};
In[1]:=result=MyFunction@data
Out[1]:={2,2,3.5,3.5,3,3,4.5,4.5,1,1,1,0}
data[[{4,8}]] represent the peaks which I want to level via MyFunction as follows:
{a___,PrePeakValue1_,peak1_,b___,PrePeakValue2_,peak2_,c___}:>{a,Mean1,Mean1,b,Mean2,Mean2,c}
whereas Mean1=Mean@{PrePeakValue1,peak1} (i.e. Mean@{2,5}) and Mean2=Mean@{PrePeakValue2,peak2} (i.e. Mean@{3,6}).
I posted this question already some time ago, but Heike's approach has one disadvantage: neither it identifies and therefor nor levels the second peak. I think using LengthWhile migth be one reason why it won't work.
EDIT:
data is just an example. I have other lists which may contain no, one or more than two peaks.

{2, 2, 2, 5, 4, 3, 3, 6, 5, 1, 1, 0}? Is it{2, 2, 3.5, 3.5, 4, 3, 4.5, 4.5, 5, 1, 1, 0}or{2., 2., 3.5, 3.75, 3.75, 3., 4.5, 4.75, 4.75, 1., 1., 0.}? – kglr May 22 '12 at 08:12{4, 10, 9, 8}? – kglr May 22 '12 at 08:26