The following result is sometimes known as the **Compression Lemma:**

Let $(X,A)$ be a CW pair and let $(Y,B)$ be a topological pair with $B\neq\emptyset$. For all $n$ such that $X-A$ has $n$-cells, assume that $\pi_n(Y,B,b_0)=0$ for all choices of basepoint $b_0\in B$. Then every map $f\colon\thinspace (X,A)\to (Y,B)$ is homotopic rel $A$ to a map with image in $B$.

See Hatcher's "Algebraic Topology", Section 4.1, or G.W. Whitehead's "Elements of Homotopy Theory", Section II.3. Using this result gives a quick route to J.H.C. Whitehead's theorem that a weak homotopy equivalence between CW complexes is a homotopy equivalence.

I am wondering whether there is a strengthening of this result which applies to individual maps, along the following lines:

Let $(X,A)$ be a CW pair with $A\neq \emptyset$ and let $(Y,B)$ be a topological pair. Let $f\colon\thinspace (X,A)\to (Y,B)$ be a map of pairs. For all $n$ such that $X-A$ has $n$-cells, assume that the induced map $f_\ast\colon\thinspace\pi_n(X,A,a_0)\to \pi_n(Y,B,f(a_0))$ is zero for all choices of basepoint $a_0\in A$, and

[insert some extra conditions, possibly homological]. Then $f$ is homotopic rel $A$ to a map with image in $B$.

Does anyone know of such a result? Perhaps this is asking too much, and that the answer may well be "this is what obstruction theory does", but I thought I'd ask just in case.