[PLAT-4922] Fix error in graph pruning logic