Mystery of different hierarchy
You must have noticed the discrepancy in the object hierarchy between the Object Spy and object repository for the same object. For example, if you spy on username field on Mercury Tours website, you will notice that it is contained in many nested webtables after Browser > Page. Whereas if the same object (username edit box) is added into the object repository, it does not show those nested tables.
QTP sieves away the extra objects in hierarchy for better readability and maintainability when objects get added into the OR. You can dig into the hierarchy and reach to the object you want to, because of the application inner control hierarchy. Like, given a parent as Browser, you can recursively run through all its children(Page, WebTable, WebTable …) until you find the username edit box control. You basically need the higher and lower level in the hierarchy to specifically point to a particular object. QTP removes the rest, as they might just function as a container or framing host for the objects.
The full hierarchy in the Object Spy enables us to identify the parent objects from where a particular object can be retrieved during run time. Object Spy is a developer tool, which helps you to get the insight of how the control are structured or the inner control structure and so it has the full description of the objects you spy, in order to provide you the complete detail of the application under test.
Object spy does not store the full description of the objects, it just displays all the information. Whereas Object Repository stores the description and properties. Just assume how bulky it will be when the OR will store the full description for each and every object. Also it will contain redundant information, which is of no use at all to you for automation. The full description in the object spy helps in descriptive programming extensively.