It might desirable to see which object we're waiting on.
To do so join to the pairs by both, locker and waiter, otherwise
duplicates are prodcued.
To do so add `dad` column to the `tree` subquery.
It was tempting to also change database and relation (wherever possible)
oids into names, but I choose not to do so.
It turns out that quite frequently single session will block others on
different objects, especially if it is idle in transaction. Therefore
get rid of the `mode` column in `leads` and `tree` subqueries and group
leads only by locker.
This lead to the change for the non-cyclic sessions. As `mode` is gone,
lockers are filtered by highest level instead.
Last change was to get rid of early cycle checks in the `leads` subquery,
as it is causing wrong results when tree is formed.
It might happen that all lockers are also waiting on some other resources,
which leads to empty output.
Properly detect locking leads via another recursive check on lockers only.
In cases where locker is holding several locks on the same entry,
make sure to use only the highest lock to avoid duplicates.
Lock mode is transfered into numeric form via array. It is possible
to convert it back, but as mode is not shown in the final output
I choose not bother.