# [Python 2], <s>55</s> 54 bytes

<!-- language-all: lang-python -->

    i=0
    for c in input():o=c<'<';print(i-o)*' '+c;i-=o*2-1

[Try it online!][TIO-j7jlvyaq]

[Python 2]: https://docs.python.org/2/
[TIO-j7jlvyaq]: https://tio.run/##K6gsycjPM/r/P9PWgCstv0ghWSEzD4gKSks0NK3ybZNt1G3UrQuKMvNKNDJ18zW11BXUtZOtM3Vt87WMdA3//1ePAQN9fTAJZ@jrq/8HAA "Python 2 – Try It Online"