Implement depth_first and inverse_depth_first range factory functions.