abstract distance and parent
handle inversions in distance and parents