budget/src/main/java/budget/backend/structures/BinaryTreeHeap.java
private void findPrev(){
		//if the deleted node was a right child, then the next node is the left child.
		if ((last.getParent()).getLeft() != null) {
			last = (last.getParent()).getLeft();
		}
		else {
			last = last.getParent(); //if the left child was null, then the parent has no more children
			//find a right child, or the root
			while ((last.getParent() != null) && (!(last.equals((last.getParent()).getRight())))){
				last = last.getParent();
			}

			//go to the other sibling, if there is any
			if (last.getParent() != null)
				last = (last.getParent()).getLeft();

			//go down right until a leaf is found
			while(!(last.isLeaf())){
				last = last.getRight();
			}
		}
	}
/**
	 * Reverse of the findNext algorithm, used to find the previous item, if the last was removed.
	 * @param parent the parent of the last node.
	 */
Reverse of the findNext algorithm, used to find the previous item, if the last was removed.
@param parent the parent of the last node.
Reverse of the findNext algorithm used to find the previous item if the last was removed . @param parent the parent of the last node .
private void findPrev(){
		if ((last.getParent()).getLeft() != null) {
			last = (last.getParent()).getLeft();
		}
		else {
			last = last.getParent(); 
			while ((last.getParent() != null) && (!(last.equals((last.getParent()).getRight())))){
				last = last.getParent();
			}
			if (last.getParent() != null)
				last = (last.getParent()).getLeft();
			while(!(last.isLeaf())){
				last = last.getRight();
			}
		}
	}
private void findPrev ( ) { if ( ( last . getParent ( ) ) . getLeft ( ) != null ) { last = ( last . getParent ( ) ) . getLeft ( ) ; } else { last = last . getParent ( ) ; while ( ( last . getParent ( ) != null ) && ( ! ( last . equals ( ( last . getParent ( ) ) . getRight ( ) ) ) ) ) { last = last . getParent ( ) ; } if ( last . getParent ( ) != null ) last = ( last . getParent ( ) ) . getLeft ( ) ; while ( ! ( last . isLeaf ( ) ) ) { last = last . getRight ( ) ; } } }
Reverse of the findNext algorithm, used to find the previous item, if the last was removed.
Reverse of the findNext algorithm used to find the previous item if the last was removed .
//if the deleted node was a right child, then the next node is the left child. //if the left child was null, then the parent has no more children //find a right child, or the root //go to the other sibling, if there is any //go down right until a leaf is found