private Object[] internalGetChildren(Object parent, boolean isElement) {
   Object element = internalGetElement(parent);
   if (element instanceof ISynchronizationScope) {
     // If the root is a scope, we want to include all models in the scope
     ISynchronizationScope rms = (ISynchronizationScope) element;
     if (rms.getMappings(getModelProviderId()).length > 0) {
       empty = false;
       return new Object[] {getModelProvider()};
     }
     empty = true;
     return new Object[0];
   } else if (element instanceof ISynchronizationContext) {
     ISynchronizationContext context = (ISynchronizationContext) element;
     // If the root is a context, we want to filter by the context
     ISynchronizationContext sc = (ISynchronizationContext) element;
     if (sc.getScope().getMappings(getModelProviderId()).length > 0) {
       Object root = getModelRoot();
       boolean initialized = isInitialized(context);
       if (!initialized
           || getChildrenInContext(sc, root, getDelegateChildren(root, isElement)).length > 0) {
         if (!initialized) requestInitialization(context);
         empty = false;
         return new Object[] {getModelProvider()};
       }
     }
     empty = true;
     return new Object[0];
   }
   if (element == getModelProvider()) {
     ISynchronizationContext context = getContext();
     if (context != null && !isInitialized(context)) {
       return new Object[0];
     }
     element = getModelRoot();
     if (parent instanceof TreePath) {
       parent = TreePath.EMPTY.createChildPath(element);
     } else {
       parent = element;
     }
   }
   Object[] delegateChildren = getDelegateChildren(parent, isElement);
   ISynchronizationContext context = getContext();
   if (context == null) {
     ISynchronizationScope scope = getScope();
     if (scope == null) {
       return delegateChildren;
     } else {
       return getChildrenInScope(scope, parent, delegateChildren);
     }
   } else {
     return getChildrenInContext(context, parent, delegateChildren);
   }
 }
 /**
  * Return whether the given element has children in the given scope. By default, true is returned
  * if the given element contains any elements in the scope or if any of the elements in the scope
  * contain the given element and the delegate provider returns children for the element. The
  * {@link ResourceMapping#contains(ResourceMapping)} is used to test for containment. Subclasses
  * may override to provide a more efficient implementation.
  *
  * @param scope the scope
  * @param element the element
  * @return whether the given element has children in the given scope
  */
 protected boolean hasChildrenInScope(ISynchronizationScope scope, Object element) {
   ResourceMapping mapping = Utils.getResourceMapping(internalGetElement(element));
   if (mapping != null) {
     ResourceMapping[] mappings = scope.getMappings(mapping.getModelProviderId());
     for (int i = 0; i < mappings.length; i++) {
       ResourceMapping sm = mappings[i];
       if (mapping.contains(sm)) {
         return true;
       }
       if (sm.contains(mapping)) {
         return getDelegateChildren(element).length > 0;
       }
     }
   }
   return false;
 }