Acessing elements on android using hierarchy?

I wanna to access (click) an element that is in deeper hierarchies (I don’t know if this concept is correct but is how I can explain) but even using xpath, I can’t reach them. Using Espresso test recorder, i could get the names of the element and parent class, in this little method:
ViewInteraction percentRelativeLayout = onView( allOf(withClassName(is("android.support.percent.PercentRelativeLayout")), withParent(withId(R.id.drawer_activity_navigation_header)), isDisplayed())); percentRelativeLayout.perform(click());
I’ve tried using xpath with hierarchy (classname[@index = ‘x’]/classname[@index = 2]) but doesn’t worked. How can I acess these kind of element?

As per my knowledge, Espresso(which I have not worked on) generates testing codes against your Android code, which you have posted here.
If you will post the Android code, then we might figure it out.

i’ve already solved the issue. Thanks anyway!