recursive merge for trait inheritance