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