question: public static List < ExecutionEntity > orderFromRootToLeaf ( Collection < ExecutionEntity > executions ) { List < ExecutionEntity > orderedList = new ArrayList < ExecutionEntity > ( executions . size ( ) ) ; HashSet < String > previousIds = new HashSet < String > ( ) ; for ( ExecutionEntity execution : executions ) { if ( execution . getParentId ( ) == null ) { orderedList . add ( execution ) ; previousIds . add ( execution . getId ( ) ) ; } } while ( orderedList . size ( ) < executions . size ( ) ) { for ( ExecutionEntity execution : executions ) { if ( ! previousIds . contains ( execution . getId ( ) ) && previousIds . contains ( execution . getParentId ( ) ) ) { orderedList . add ( execution ) ; previousIds . add ( execution . getId ( ) ) ; } } } return orderedList ; }
target:  Takes in a collection of executions belonging to the same process instance. Orders the executions in a list, first elements are the leaf, last element is the root elements.