return createCompoundElements((IPackageFragment[]) children.toArray(new IPackageFragment[children.size()]));
return combineSamePackagesIntoLogialPackages((IPackageFragment[]) children.toArray(new IPackageFragment[children.size()]));
	public Object[] getChildren(Object parentElement) {		try {			if (parentElement instanceof IJavaElement) {				IJavaElement iJavaElement= (IJavaElement) parentElement;				int type= iJavaElement.getElementType();				switch (type) {					case IJavaElement.JAVA_PROJECT :						{							//create new element mapping							fMapToCompoundElement= new HashMap();							fProjectViewState= true;							IJavaProject project= (IJavaProject) parentElement;							IPackageFragment[] topLevelChildren= getTopLevelChildrenByElementName(project.getPackageFragments());							List list= new ArrayList();							for (int i= 0; i < topLevelChildren.length; i++) {								IPackageFragment fragment= topLevelChildren[i];								IJavaElement el= fragment.getParent();								if (el instanceof IPackageFragmentRoot) {									IPackageFragmentRoot root= (IPackageFragmentRoot) el;									if (!root.isArchive() || !root.isExternal())										list.add(fragment);								}							}							return createCompoundElements((IPackageFragment[]) list.toArray(new IPackageFragment[list.size()]));						}					case IJavaElement.PACKAGE_FRAGMENT_ROOT :						{							IPackageFragmentRoot root= (IPackageFragmentRoot) parentElement;							fProjectViewState= false;									//create new element mapping							fMapToCompoundElement= new HashMap();							IResource resource= root.getUnderlyingResource();							IPackageFragment[] fragments= new IPackageFragment[0];							if (root.isArchive()) {								IJavaElement[] els= root.getChildren();								fragments= getTopLevelChildrenByElementName(els);							} else if (resource != null && resource instanceof IFolder) {								fragments= getTopLevelChildrenByElementName(root.getChildren());							}							addFragmentsToMap(fragments);							return fragments;						}					case IJavaElement.PACKAGE_FRAGMENT :						{							IPackageFragment packageFragment= (IPackageFragment) parentElement;							IPackageFragment[] fragments= new IPackageFragment[0];							IJavaElement parent= packageFragment.getParent();							if (parent instanceof IPackageFragmentRoot) {								IPackageFragmentRoot root= (IPackageFragmentRoot) parent;								fragments= findNextLevelChildrenByElementName(root, packageFragment);							}							addFragmentsToMap(fragments);							return fragments;						}				}							//@Improve: rewrite using concatenate				} else if (parentElement instanceof LogicalPackage) {				List children= new ArrayList();				LogicalPackage compoundEl= (LogicalPackage) parentElement;				IPackageFragment[] elements= compoundEl.getFragments();				for (int i= 0; i < elements.length; i++) {					IPackageFragment fragment= elements[i];					IPackageFragment[] objects= findNextLevelChildrenByElementName((IPackageFragmentRoot) fragment.getParent(), fragment);					children.addAll(Arrays.asList(objects));				}				return createCompoundElements((IPackageFragment[]) children.toArray(new IPackageFragment[children.size()]));			}		} catch (JavaModelException e) {			JavaPlugin.log(e);		}		return new Object[0];	}