Restructuring node hierarchy