Restructuring tree structure for easier linking