public ContextItem[] findCtxItems(int[] ctxTypes, String name) { List<ContextItem> out = new ArrayList<ContextItem>(); // todo -- subject to simplify if (name == null) { for (List<TreeNodeImpl> children : root.childs.values()) { for (TreeNode n : children) { if (hitted(n.getType(), ctxTypes)) { out.add(new ContextItemImpl(n.getPath(), n.getValue())); } } } } else { List<TreeNodeImpl> children = root.childs.get(name); if (children != null) { for (TreeNode n : children) { if (hitted(n.getType(), ctxTypes)) { out.add(new ContextItemImpl(n.getPath(), n.getValue())); } } } } return out.toArray(new ContextItem[out.size()]); }