Refactor graph tree