Detect and merge duplicate predicates 'AND(x, y, x)' to 'AND(x, y)' in more circumstances.

Make flattenAnd and flattenOr more efficient on empty lists.
[CALCITE-448] PushFilterIntoJoinRule creates filters containing invalid RexInputRef