The stochastic motion in a nonhomogeneous medium with traps is studied and diffusion properties of that system are discussed. The particle is subjected to a stochastic stimulation obeying a general Lévy stable statistics and experiences long rests due to nonhomogeneously distributed traps. The memory is taken into account by subordination of that process to a random time; then the subordination equation is position-dependent. The problem is approximated by a decoupling of the medium structure and memory and exactly solved for a power-law position dependence of the memory. In the case of the Gaussian statistics, the density distribution and moments are derived: depending on geometry and memory parameters, the system may reveal both the subdiffusion and enhanced diffusion. The similar analysis is performed for the Lévy flights where the finiteness of the variance follows from a variable noise intensity near a boundary. Two diffusion regimes are found: in the bulk and near the surface. The anomalous diffusion exponent as a function of the system parameters is derived.