PolishNotation algorithm implementation (using Composite pattern)