Implement GetNestedHierarchy() for Markdown

Fixes part of #1546