recursive merge