private void updateCollapsedGraph() {
   UnsignedBitSet initVisibility =
       ReachableNodes.getReachableNodes(
           myPermanentGraphInfo.getPermanentLinearGraph(), myIdsOfVisibleBranches);
   myCollapsedGraph =
       CollapsedGraph.newInstance(getDelegateController().getCompiledGraph(), initVisibility);
 }
 @NotNull
 @Override
 public Set<CommitId> getContainingBranches(@NotNull CommitId commit) {
   int commitIndex = myPermanentCommitsInfo.getNodeId(commit);
   return myPermanentCommitsInfo.convertToCommitIdSet(
       myReachableNodes.getContainingBranches(commitIndex, myBranchNodeIds));
 }
 @NotNull
 @Override
 public Condition<CommitId> getContainedInBranchCondition(
     @NotNull final Collection<CommitId> heads) {
   List<Integer> headIds =
       ContainerUtil.map(
           heads,
           new Function<CommitId, Integer>() {
             @Override
             public Integer fun(CommitId head) {
               return myPermanentCommitsInfo.getNodeId(head);
             }
           });
   if (!heads.isEmpty() && ContainerUtil.getFirstItem(heads) instanceof Integer) {
     final TIntHashSet branchNodes = new TIntHashSet();
     myReachableNodes.walk(
         headIds,
         new Consumer<Integer>() {
           @Override
           public void consume(Integer node) {
             branchNodes.add((Integer) myPermanentCommitsInfo.getCommitId(node));
           }
         });
     return new Condition<CommitId>() {
       @Override
       public boolean value(CommitId commitId) {
         return branchNodes.contains((Integer) commitId);
       }
     };
   } else {
     final Set<CommitId> branchNodes = ContainerUtil.newHashSet();
     myReachableNodes.walk(
         headIds,
         new Consumer<Integer>() {
           @Override
           public void consume(Integer node) {
             branchNodes.add(myPermanentCommitsInfo.getCommitId(node));
           }
         });
     return new Condition<CommitId>() {
       @Override
       public boolean value(CommitId commitId) {
         return branchNodes.contains(commitId);
       }
     };
   }
 }
  @NotNull
  public static UnsignedBitSet getReachableNodes(
      @NotNull PermanentLinearGraphImpl permanentGraph, @Nullable Set<Integer> headNodeIndexes) {
    if (headNodeIndexes == null) {
      UnsignedBitSet nodesVisibility = new UnsignedBitSet();
      nodesVisibility.set(0, permanentGraph.nodesCount() - 1, true);
      return nodesVisibility;
    }

    assert !headNodeIndexes.isEmpty();

    final UnsignedBitSet result = new UnsignedBitSet();
    ReachableNodes getter = new ReachableNodes(LinearGraphUtils.asLiteLinearGraph(permanentGraph));
    getter.walk(
        headNodeIndexes,
        new Consumer<Integer>() {
          @Override
          public void consume(Integer node) {
            result.set(node, true);
          }
        });

    return result;
  }