prevSibling method

bool prevSibling()

Select prev child node in parent of current node.

Consider tree:

       S1
      /  \
     S2  S3

if current node is S3, after call to this method S2 will be current node. If prev sibling is selected, method returns true. If there is no prev sibling this method do nothing, and returns false.

Implementation

bool prevSibling() {
  if (_current == _root) {
    return false;
  }
  ProcessingNode parent = _parenthood[_current]!;
  int index = parent.children.indexOf(_current);
  index--;
  if (index < 0) {
    return false;
  }
  _current = parent.children[index];
  return true;
}