x^2-6xy+9y^2+x^2y-9y^3
=(x-3y)^2+y(x^2-9y^2)
=(x-3y)^2+y(x+3y)(x-3y)
=(x-3y)[x-3y+y(x+3y)]
=(x-3y)(x-3y+xy+3y^2)