AntBuildTarget[] (TreePath[] paths) { return Arrays.stream(paths) .map(path -> ((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject()) .filter(userObject -> userObject instanceof AntTargetNodeDescriptor) .map(userObject -> ((AntTargetNodeDescriptor)userObject).getTarget()) .toArray(AntBuildTarget[]::new); }