Bounding $|f(z)|$ via Schwarz So I have asked something about this questions before (a while ago) and someone gave me a hint and I thought I had got it. Unfortunately, I was reviewing some old proofs and I realized that I had made some silly errors. The questions is as follows.

Let f be analytic in an open set which contains the closed unit disc $\overline{\mathbb{D}},$ and assume $M:=\max\{\textrm{Re}(f):|z|=1\}\geq0.$ Prove that for $z\in\mathbb{D},$ $$|f(z)|\leq \frac{1+|z|}{1-|z|}[M+|f(0)|].$$

If I define $$g(z):=\frac{M-f(z)}{M-f(0)},$$ then I have that $g:\mathbb{D}\rightarrow\{z\in\mathbb{C}: Re[z]>0\}$ with $0\mapsto 1.$ Now defining $m(z)=\frac{z-1}{z+1}$ we have
$$ |(m\circ g)(z)|\leq |z|\Rightarrow 
\left|\frac{\frac{M-f(z)}{M-f(0)}-1}{\frac{M-f(z)}{M-f(0)}+1}\right| \leq |z|
\Rightarrow \left| \frac{f(0)-f(z)}{2M-f(z)-f(0)} \right| \leq |z| \\
\Rightarrow |f(z)|-|f(0)| \leq 2M|z|+|f(z)||z|+|f(0)||z|
\Rightarrow |f(z)| \leq \frac{2M|z|}{1-|z|} + \frac{1+|z|}{1-|z|}|f(0)|.$$
I can't see anywhere were I made an error or how to use this to get the bound that I am after.

As already mentioned in the comments, $(M - f(z))/(M - f(0))$
does not necessarily have positive real part. If you define
$$
 g(z) = M - f(z)
$$
instead then $g$ has positive real part (assuming that $f$
is not constant). Therefore
$$
 h(z) = \frac{g(z) - g(0)}{g(z) + \overline{g(0)}}
 = \frac{f(0) - f(z)}{2M -f(z) + \overline{f(0)}}
$$
maps into the unit disk with $h(0) = 0$, and you can apply the Schwarz lemma:
$|h(z)| \le |z|$.
This actually leads to the same estimate
$$
|f(z)| \leq \frac{2M|z|}{1-|z|} + \frac{1+|z|}{1-|z|}|f(0)|
$$
Now just observe that
$2|z| < 1 + |z|$ and therefore
$$
\frac{2M|z|}{1-|z|} < \frac{1+|z|}{1-|z|}M \, .
$$
