@Nullable private Collection<GridClientNode> intersection(@Nullable Collection<? extends GridClientNode> first,@Nullable Collection<? extends GridClientNode> second){
  if (first == null && second == null)   return null;
  if (first != null && second != null) {
    Collection<GridClientNode> res=new LinkedList<>(first);
    res.retainAll(second);
    return res;
  }
 else   return new ArrayList<>(first != null ? first : second);
}

@ Nullable private Collection < GridClientNode > intersection ( @ Nullable Collection < ? extends GridClientNode > first , @ Nullable Collection < ? extends GridClientNode > second ) { if ( first == null && second == null ) return null ; if ( first != null && second != null ) { Collection < GridClientNode > res = new LinkedList < > ( first ) ; res . retainAll ( second ) ; return res ; } else return new ArrayList < > ( first != null ? first : second ) ; }
calculates intersection of two collections . returned collection always a new collection .
