int justPrevNode = -1;
while (nextNode != -1) {
int parent = tree.parent(nextNode);
if (prevNode.containsKey(parent)) {
int prevNodeId = prevNode.get(parent);
if (tree.childCount(prevNodeId) <= 1 && tree.childCount(nextNode) <= 1) {
tree.addCount(prevNodeId, tree.count(nextNode));
tree.addCount(nextNode, -1 * tree.count(nextNode));
if (tree.childCount(nextNode) == 1) {