ActionUrl[] (DefaultMutableTreeNode node, ActionUrl parent) { ArrayList<ActionUrl> result = new ArrayList<>(); ArrayList<String> groupPath = new ArrayList<>(parent.getGroupPath()); for (int i = 0; i < node.getChildCount(); i++) { DefaultMutableTreeNode child = (DefaultMutableTreeNode)node.getChildAt(i); ActionUrl url = new ActionUrl(); url.setGroupPath(groupPath); final Object userObject = child.getUserObject(); url.setComponent(userObject instanceof Pair ? ((Pair<?, ?>)userObject).first : userObject); result.add(url); } return result.toArray(new ActionUrl[0]); }