void (@NotNull MoveType type, @NotNull JTree tree) { TreePath lead = tree.getLeadSelectionPath(); Rectangle bounds = tree.getPathBounds(lead); if (lead == null || bounds == null) { selectLast(type, tree); } else { int height = Math.max(tree.getVisibleRect().height - bounds.height * 4, 1); TreePath next = tree.getClosestPathForLocation(bounds.x, bounds.y + bounds.height + height); if (next != null && !next.equals(lead)) select(type, tree, next); } }