Example 5 Given the set $M=\left\{x \mid x^{2}-2 x+m=0, x \in \mathbf{R}\right\}$ is non-empty, then the sum of all elements in set $M$ is $\qquad$ .
When $m=1$, the set $M$ contains only the unique element 1;
When $m \neq 1$, the set $M$ contains two different elements $x_{1}$ and $x_{2}$, and $x_{1}+x_{2}=2$. Therefore, the sum of all elements in the set is 1 or 2.

Solution Guide: Generally, for a non-empty set $\left\{x \mid a x^{2}+b x+c=0, x \in \mathbf{R}\right\}$, where $a \neq 0$, $a, b, c \in \mathbf{R}$, the sum of the elements in set $A$ has two scenarios: (1) $\Delta=b^{2}-4 a c=0$, the sum is $-\frac{b}{2 a}$; (2) $\Delta=b^{2}-4 a c>0$, the sum is $-\frac{b}{a}$. If the condition $a \neq 0$ is removed, there is another case where the sum of elements in $A$ is $-\frac{c}{b}$. Pay attention to classification and discussion, and be rigorous in thinking.