The primary problem in property testing is to decide whether a given function satisfies a certain property, or is far from any function satisfying it. This crucially requires a notion of distance between functions. The most prevalent notion is the Hamming distance over the uniform distribution on the domain. This restriction to uniformity is more a matter of convenience than of necessity, and it is important to investigate distances induced by more general distributions. In this paper, we make significant strides in this direction. We give simple and optimal testers for bounded derivative properties over arbitrary product distributions. Bounded derivative properties include fundamental properties such as monotonicity and Lipschitz continuity. Our results subsume almost all known results (upper and lower bounds) on monotonicity and Lipschitz testing.We prove an intimate connection between bounded derivative property testing and binary search trees (BSTs). We exhibit a tester whose query complexity is the sum of expected depths of optimal BSTs for each marginal. Furthermore, we show this sum-of-depths is also a lower bound. A fundamental technical contribution of this work is an optimal dimension reduction theorem for all bounded derivative properties, which relates the distance of a function from the property to the distance of restrictions of the function to random lines. Such a theorem has been elusive even for monotonicity for the past 15 years, and our theorem is an exponential improvement to the previous best known result.This means the rth-partial derivative of f is bounded by quantities that only depend on the rth coordinate. Note that this dependence is completely arbitrary, and different dimensions can have completely different bounds. This forms a rich class of properties which includes monotonicity and c-Lipschitz continuity. To get monotonicity, simply set l r (y) = 0 and u r (y) = ∞ for all r. To get c-Lipschitz continuity, set l r (y) = −c and u r (y) = +c for all r. The class also includes the property demanding monotonicity for some (fixed) coordinates and the c-Lipschitz continuity for others; and the non-uniform Lipschitz property that demands different Lipschitz constants for different coordinates.Definition 1.2. Fix a bounding family B and product distribution D = r≤d D r . Define dist D (f, g) = Pr x∼D [f (x) = g(x)]. A property tester for P(B) with respect to D takes as input proximity parameter ε > 0 and has query access to function f . If f ∈ P(B), the tester accepts with probability > 2/3. If dist D (f, P(B)) > ε, the tester rejects with probability > 2/3.