How do we factor out $x^2 - x -2$ in this expression? Suppose we're given that
$$x^4 - 2x^3 +x-2$$
How do we factor out $x^2 - x -2$ in this expression?

$$(x^4 -x^3- 2x^2)-(x^3-x^2-2x)+(x^2-x-2) = x^2(x^2 -x-2)-x(x^2-x-2)+(x^2-x-2) = (x^2-x-2)(x^2-x+1)$$

This satisfies with what we want to get. However, I do not seem to have understood what is done there. Could I get your assistance in order to understand it? Perhaps there's better way of factoring. 
Regards

Note that
$$x^4-2x^3+x-2 = x^3(x-2)+1(x-2)=(x-2)(x^3+1)=\color{red}{(x-2)(x+1)}(x^2-x+1).$$

Regarding the taking a factor out part, we use
$$ab+ac = a(b+c)$$
to factor $a$ out of the terms. In your case, it is $ab+ac+ad = a(b+c+d)$.
