MemoryStateChange (@NotNull MemoryStateChange change) { if (change == this) return this; Set<MemoryStateChange> previous = new LinkedHashSet<>(); if (myInstruction instanceof MergeInstruction) { previous.addAll(myPrevious); } else { previous.add(this); } if (change.myInstruction instanceof MergeInstruction) { previous.addAll(change.myPrevious); } else { previous.add(change); } if (previous.size() == 1) { return previous.iterator().next(); } return new MemoryStateChange(new ArrayList<>(previous), new MergeInstruction(), Collections.emptyMap(), myTopOfStack.getFactory().getUnknown(), Collections.emptyMap()); }