Assuming you already have the AFElement representing the child element, we can find all the parent Elements that has a reference to the child element like:
OSIsoft.AF.AFNamedCollection<AFElement> parents = child.Parents;
foreach (AFElement p in parents)
Hope this helps
works too and will return all paths. For example, given this hierarchy:
string paths = myElement.GetPaths()
Y has one parent, but its parent, X, has two.
Y.GetPaths() will return A\X\Y and B\X\Y, where as the first code would only produce A\X\Y