\(xy\left(x+y\right)-yz\left(z+y\right)+xz\left(x-z\right)\)
\(=xy\left(x-z+z+y\right)-yz\left(z+y\right)+xz\left(x-z\right)\)
\(=\left[xy\left(x-z\right)+xz\left(x-z\right)\right]+\left[xy\left(z+y\right)-yz\left(z+y\right)\right]\)
\(=\left(x-z\right)\left(xy+xz\right)+\left(y+z\right)\left(xy-yz\right)\)
\(=\left(x-z\right)x\left(y+z\right)+\left(y+z\right)y\left(x-z\right)\)
\(=\left(x-z\right)\left(y+z\right)\left(x+y\right).\)