// Swap them so that duplicate removal happens first (it's lower in the plan) ...
PlanNode parent = distinct.getParent();
PlanNode sort = distinct.getFirstChild();
assert sort.getParent() == distinct;
// First, remove SORT from DUP_REMOVE (which will be empty) ...
sort.removeFromParent();
assert sort.getParent() == null;
// Move all children of SORT into the currently-empty DUP_REMOVE ...
distinct.addChildren(sort.getChildren());
assert sort.getChildCount() == 0;
assert sort.getParent() == null;