Solutions to the two-body problem in general relativity allow us to predict the mass, spin and recoil velocity of a black-hole merger remnant given the masses and spins of its binary progenitors. In this paper we address the inverse problem: given a binary black-hole merger, can we use the parameters measured by gravitational-wave interferometers to tell if the binary components are of hierarchical origin, i.e. if they are themselves remnants of previous mergers? If so, can we determine at least some of the properties of their parents? This inverse problem is in general overdetermined. We show that hierarchical mergers occupy a characteristic region in the plane composed of the effective spin parameters $chi_{rm eff}$ and $chi_{rm p}$, and therefore a measurement of these parameters can add weight to the hierarchical-merger interpretation of some gravitational-wave events, including GW190521. If one of the binary components has hierarchical origin and its spin magnitude is well measured, we derive exclusion regions on the properties of its parents: for example we infer that the parents of GW190412 (if hierarchical) must have had unequal masses and low spins. Our formalism is quite general, and it can be used to infer constraints on the astrophysical environment producing hierarchical mergers.