I am trying to figure out how to provide access to nodes of the users, which have referenced users. Please note that users are referenced not from nodes, but the user profiles, so I can not use the Node access user reference module. I also can not use roles-based access modules, because otherwise there would be too many roles to create as users on this website should be able to reference unlimited users. I also can not user organic groups.
So basically users have other users referenced from their profiles. All referenced users should have access to nodes authored by the users who referenced them.