Couple<DirDiffElementImpl> (DirDiffTableModel model) { List<DirDiffElementImpl> elements = model.getSelectedElements(); if (elements.size() != 2) return null; DirDiffElementImpl source = ContainerUtil.find(elements, DirDiffElementImpl::isSource); DirDiffElementImpl target = ContainerUtil.find(elements, DirDiffElementImpl::isTarget); if (source == null || target == null || source.getParentNode() != target.getParentNode()) return null; return Couple.of(source, target); }