boolean (@NotNull LeafBlockWrapper first, @NotNull LeafBlockWrapper second, @NotNull Map<AbstractBlockWrapper, Set<AbstractBlockWrapper>> alignmentMappings) { Set<AbstractBlockWrapper> blocksBeforeCurrent = new HashSet<>(); for ( LeafBlockWrapper previousBlock = second.getPreviousBlock(); previousBlock != null; previousBlock = previousBlock.getPreviousBlock()) { Set<AbstractBlockWrapper> blocks = alignmentMappings.get(previousBlock); if (blocks != null) { blocksBeforeCurrent.addAll(blocks); } if (previousBlock.getWhiteSpace().containsLineFeeds()) { break; } } for ( LeafBlockWrapper next = first.getNextBlock(); next != null && !next.getWhiteSpace().containsLineFeeds(); next = next.getNextBlock()) { if (blocksBeforeCurrent.contains(next)) { return false; } } return true; }