Stav dette: Building merger trees from cosmological N-body simulations