Deluge script to record level sharing

Deluge script to record level sharing

Hi, how can we check to whom a specific record is shared? 
 and how can we record level share a specific record?

Example: USER X owns "ACCOUNT A"s record, and all "ACCOUNT A" Potentials (we do this thru a custom function that puts potentials owner = account owner)...
USER X shares "ACCOUNT A" and POTENTIAL 1 with USER Y....
When USER Y creates a new "ACCOUNT A" potential... the system creates it but USER Y is not able to see it, because USER X becomes the record owner (again thru our custom function)

If we could check via a script to whom the records are shared with and share them right there with a custom function, then USER X would not have to share the record manually...

Appreciate your help

Julio