@NotNull public static Map<RadComponent,List<RadComponent>> groupSiblings(@NotNull List<? extends RadComponent> components){
  Map<RadComponent,List<RadComponent>> siblingLists=new HashMap<RadComponent,List<RadComponent>>();
  if (components.isEmpty()) {
    return siblingLists;
  }
  if (components.size() == 1) {
    RadComponent component=components.get(0);
    siblingLists.put(component.getParent(),Collections.singletonList(component));
    return siblingLists;
  }
  for (  RadComponent component : components) {
    RadComponent parent=component.getParent();
    List<RadComponent> children=siblingLists.get(parent);
    if (children == null) {
      children=new ArrayList<RadComponent>();
      siblingLists.put(parent,children);
    }
    children.add(component);
  }
  return siblingLists;
}

@ NotNull public static Map < RadComponent , List < RadComponent > > groupSiblings ( @ NotNull List < ? extends RadComponent > components ) { Map < RadComponent , List < RadComponent > > siblingLists = new HashMap < RadComponent , List < RadComponent > > ( ) ; if ( components . isEmpty ( ) ) { return siblingLists ; } if ( components . size ( ) == 1 ) { RadComponent component = components . get ( 0 ) ; siblingLists . put ( component . getParent ( ) , Collections . singletonList ( component ) ) ; return siblingLists ; } for ( RadComponent component : components ) { RadComponent parent = component . getParent ( ) ; List < RadComponent > children = siblingLists . get ( parent ) ; if ( children == null ) { children = new ArrayList < RadComponent > ( ) ; siblingLists . put ( parent , children ) ; } children . add ( component ) ; } return siblingLists ; }
partitions the given list of components into a map where each value is a list of siblings , in the same order as in the original list , and where the keys are the parents ( or null for the components that do not have a parent ) . < p / > the value lists will never be empty . the parent key will be null for components without parents .
