@Override
  public Object[] getElements(Object inputElement) {
    if (inputElement instanceof List) {
      for (Object element : (List<?>) inputElement)
        if (element instanceof ICContainer)
          try {
            ICElement[] array = ((ICContainer) element).getChildren();
            ArrayList<ICElement> output = new ArrayList<>();

            for (ICElement item : array) {
              if ((item instanceof ICContainer) && checkForValidChildren((ICContainer) item)) {
                output.add(item);
              }

              if (SystemTapLaunchShortcut.validElement(item)) {
                output.add(item);
              }
            }
            return output.toArray();
          } catch (CModelException e) {
            e.printStackTrace();
          }
    }
    return null;
  }
 @Override
 public boolean hasChildren(Object element) {
   if (element instanceof ICContainer) {
     try {
       if (((ICContainer) element).getChildren().length > 0) return true;
     } catch (CModelException e) {
       e.printStackTrace();
     }
   }
   return false;
 }
  /**
   * A container is valid if any of its children are valid c/cpp elements or if it contains another
   * container for which the above holds
   *
   * @param cont
   * @return
   */
  private boolean checkForValidChildren(ICContainer cont) {
    try {
      for (ICElement child : cont.getChildren()) {

        if ((child != null) && SystemTapLaunchShortcut.validElement(child)) return true;
        if ((child instanceof ICContainer) && checkForValidChildren((ICContainer) child)) {
          return true;
        }
      }
    } catch (CModelException e) {
      e.printStackTrace();
    }

    return false;
  }
  @Override
  public Object[] getChildren(Object parentElement) {

    ArrayList<Object> output = new ArrayList<>();

    if (parentElement instanceof ICContainer) {
      try {
        Object[] list = ((ICContainer) parentElement).getChildren();
        for (Object item : list) {
          if (item instanceof ICContainer) {
            if (checkForValidChildren((ICContainer) item)) output.add(item);
          } else if (item instanceof ICElement) {
            ICElement el = (ICElement) item;
            if (SystemTapLaunchShortcut.validElement(el)) output.add(el);
          }
        }

        return output.toArray();
      } catch (CModelException e) {
        e.printStackTrace();
      }
    }
    return null;
  }