FragmentNode () { TreePath[] selectionPaths = myTree.getSelectionPaths(); if (ArrayUtil.isEmpty(selectionPaths)) { return null; } for (TreePath path : selectionPaths) { List<FragmentNode> nodes = getFragmentNodes(path); if (!nodes.isEmpty()) { return nodes.get(0); } } return null; }