C (gcc), 43 bytes
f(n,i){for(i=1;n%++i;);n=i<n&&f(n/i)^i?:i;} Returns p if n is almost-prime, and 1 otherwise.
f(n,i){ for(i=1;n%++i;); // identify i = the least prime factor of n n=i<n&&f(n/i)^i // if n is neither prime nor almost-prime ? // return 1 :i; // return i }