code: public static List<Node> removeNestedChangeScopeNodes(List<Node> scopeNodes) {
      Set<Node> uniqueScopeNodes = new LinkedHashSet<>(scopeNodes);
      for (Node scopeNode : scopeNodes) {
        for (Node ancestor = scopeNode.getParent();
            ancestor != null;
            ancestor = ancestor.getParent()) {
          if (isChangeScopeRoot(ancestor) && uniqueScopeNodes.contains(ancestor)) {
            uniqueScopeNodes.remove(scopeNode);
            break;
          }
        }
      }
      return new ArrayList<>(uniqueScopeNodes);
    }
docs: Removes any scope nodes from the provided list that are nested within some other scope node
  also in the list. Returns the modified list.