sObjectHierarchy

any sobject with self lookup relationship.

<apex:page standardController="Account" standardStylesheets="false" showHeader="false">
    <apex:form >
        <c:RN_sObjectHierarchy sObjectName="Account" relationshipFieldName="ParentId" sObjectId="{!account.Id}" sObjectFields="Name, Phone, Type, AccountNumber, Rating"/>
    </apex:form>
</apex:page>

Account hierarchy

<apex:page standardController="contact" standardStylesheets="false" showHeader="false">
    <apex:form >
        <c:RN_sObjectHierarchy sObjectName="contact" relationshipFieldName="ratan__ParentContactId__c" sObjectId="{!contact.Id}" sObjectFields="Name, Phone, Email, Title"/>
    </apex:form>
</apex:page>

Note: Here ratan__ParentContactId__c is a custom field(self lookup) on Contact sObject.

Account hierarchy

Installtion Package