Per WS API object model a HierarchiclaRequirement object has Parent
attribute that points to another HierarchiclaRequirement (a Parent story), a Feature
attribute that references PI/Feature object that could be either its direct PI/Feature parent or the parent of it's parent user story, and a PortfolioItem
attribute that points to its immediate PI/Feature parent
Given this scenario and hierarchiclarequirement queries below: US1 parent story and US2 child story, and the PI/Feature "parent" of US1 is F1:
(PortfolioItem.FormattedID = F1)
returns US1 that has a parent Feature. It does not return US2.
(Feature.FormattedID = F1)
returns both the epic and it's child, US1 and US2.