Locally optimizes (parts of) the current tree.
When called from the 'Tree optimization' window, the optimization is always applied to the whole tree. When called via ´NNI-mode´, it depends on where you click to. The settings from ´Tree optimization´ are used to select the branches to optimize (e.g. marked and/or visible only).
At each such branch, this optimization attempts one NNI (see ´NNI (Nearest Neighbour Interchange)´). If the tree topology improves by that modification, it will be kept. Otherwise it will be undone.
If a better topology has been found, the recursion starts again (and again...) until no NNI further improved the tree (see ´NNI-mode´ for exceptions).