int (@NotNull JTree tree, int row, boolean up) { TreePath curPath; int curRow = row; do { if (up) { curRow--; } else { curRow++; } curPath = tree.getPathForRow(curRow); } while (curPath != null && DefaultTreeUI.isSeparator(curPath)); return curRow; }