Refactor parser and getDisplayNode to support more complicated situations