Handle node collapsing