Add endings parsing.
Implement ending tree.