  To measure the mass of foreground objects with weak gravitational lensing,
one needs to estimate the redshift distribution of lensed background sources.
This is commonly done in an empirical fashion, i.e. with a reference sample of
galaxies of known spectroscopic redshift, matched to the source population. In
this work, we develop a simple decision tree framework that, under the ideal
conditions of a large, purely magnitude-limited reference sample, allows an
unbiased recovery of the source redshift probability density function p(z), as
a function of magnitude and color. We use this framework to quantify biases in
empirically estimated p(z) caused by selection effects present in realistic
reference and weak lensing source catalogs, namely (1) complex selection of
reference objects by the targeting strategy and success rate of existing
spectroscopic surveys and (2) selection of background sources by the success of
object detection and shape measurement at low signal-to-noise. For
intermediate-to-high redshift clusters, and for depths and filter combinations
appropriate for ongoing lensing surveys, we find that (1) spectroscopic
selection can cause biases above the 10 per cent level, which can be reduced to
5 per cent by optimal lensing weighting, while (2) selection effects in the
shape catalog bias mass estimates at or below the 2 per cent level. This
illustrates the importance of completeness of the reference catalogs for
empirical redshift estimation.
