[BUG #7226] fixed treeutil.selectNode

- a case was not handled where node was assigned None, and then access to
  node was continued
- re-wrote the entire function as a recursive function, with better readable case
  switch of the current selector part
- also fixed a missing type cast that spoilt the exception message in
  tree.getChild()