Check parent classes in PathHelper

This fixes the case where an attachment object is a Doctrine proxy