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