Clone array of selected nodes in get_selected method

Currently, get_selected(true) is called, a new array is returned (so the user is free to edit it), however get_selected(false) returns the same array which is used internally.

Therefore the internal array can be directly edited, causing issues such as not being able to reselect nodes.

This commit just slices the the array before returning it, so a clone of the array is returned.