@Override
    protected IrRowPattern visitIrConcatenation(IrConcatenation node, Boolean inExclusion) {
      List<IrRowPattern> children =
          node.getPatterns().stream()
              .map(pattern -> process(pattern, inExclusion))
              .collect(toImmutableList());

      // flatten concatenation and remove all empty children
      children =
          children.stream()
              .flatMap(
                  child -> {
                    if (child instanceof IrConcatenation) {
                      return ((IrConcatenation) child).getPatterns().stream();
                    }
                    return Stream.of(child);
                  })
              .filter(child -> !(child instanceof IrEmpty))
              .collect(toImmutableList());

      if (children.isEmpty()) {
        return new IrEmpty();
      }
      if (children.size() == 1) {
        return children.get(0);
      }
      return new IrConcatenation(children);
    }
Flatten the concatenation and remove all empty branches. This method recursively inlines
sub-pattern lists from child concatenations into the top-level concatenation. The expected
sub-pattern order is reflected in the resulting order of the elements. Also, all empty
branches are removed from the resulting sub-pattern list. Examples: A (B C) -> A B C (A B)
((C D) E) -> A B C D E A (() B) -> A B (A ()) ((() B) ()) -> A B () (() A) -> A (() ()) () ->
()

@return the flattened IrConcatenation containing no empty branches, or a sub-pattern in case
    when the concatenation is reduced to a single branch, or IrEmpty in case when all
    sub-patterns are empty
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/rowpattern/IrRowPatternFlattener.java