fix DOM layout for more than 2 nested nodes