added pruning for unneeded local nodes