ArrangementMatchCondition (ArrangementMatchCondition @NotNull ... nodes) { final ArrangementCompositeMatchCondition result = new ArrangementCompositeMatchCondition(); final ArrangementMatchConditionVisitor visitor = new ArrangementMatchConditionVisitor() { @Override public void visit(@NotNull ArrangementAtomMatchCondition node) { result.addOperand(node); } @Override public void visit(@NotNull ArrangementCompositeMatchCondition node) { for (ArrangementMatchCondition operand : node.getOperands()) { operand.invite(this); } } }; for (ArrangementMatchCondition node : nodes) { node.invite(visitor); } return result.getOperands().size() == 1 ? result.getOperands().iterator().next() : result; }