def _get_unapplied_migrations(self, loader):
        """
        Output a list of unapplied migrations in the form [['migration1', migration2'], ...].
        This implementation is mostly copied from the Django 'showmigrations' mgmt command.
        https://github.com/django/django/blob/stable/1.8.x/django/core/management/commands/showmigrations.py

        This should only be called from _get_current_migration_state().
        """
        unapplied = []
        graph = loader.graph
        plan = []
        seen = set()

        # Generate the plan, in the order that migrations have been/should be applied.
        for target in graph.leaf_nodes():
            for migration in graph.forwards_plan(target):
                if migration not in seen:
                    plan.append(graph.nodes[migration])
                    seen.add(migration)

        # Remove the migrations that have already been applied.
        for migration in plan:
            if not (migration.app_label, migration.name) in loader.applied_migrations:
                # NOTE: Unicode Django application names are unsupported.
                unapplied.append([migration.app_label, str(migration.name)])
        return unapplied