It depends on what you are doing. Unix domain sockets translate transmitted pids.
Readlink on /proc/self reports your pid in the pid namespace of the proc mount.
That should cover most day to day cases.
Processes in pid namespaces can not escape so process nesting mirrors pid namespace nesting.
With the pid namespace file descriptors you can find can with care mount proc for each of the pid namespaces.
For a process with children you will need to look at something like start time to distinguish between them. A little tricky but it should be doable. Process with parents outside the pid namespace will report their parent pid as 0, so should be easy to find. Normally there will be only one.